Skip to content

Commit

Permalink
v2 image push: it works, but no signature yet
Browse files Browse the repository at this point in the history
  • Loading branch information
vbatts committed Aug 29, 2014
1 parent 4e99c9b commit 88d3e14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions graph/push.go
Expand Up @@ -228,6 +228,9 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
return job.Error(err2)
}

if len(tag) == 0 {
tag = DEFAULTTAG
}
// XXX TESTING
// 1) Check if TarSum of each layer exists /v2/
// 1.a) if 200, continue
Expand All @@ -240,7 +243,7 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
// XXX wait this requires having the TarSum of the layer.tar first
// skip this step for now. Just push the layer every time for this naive implementation
//shouldPush, err := r.PostV2ImageMountBlob(imageName, sumType, sum string, token []string)
var manifestData map[string][]byte
var manifestData = make(map[string][]byte)

// XXX unfortunately this goes from child to parent,
// but the list of blobs in the manifest is expected to go parent to child
Expand All @@ -267,6 +270,8 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
localChecksum := tsRdr.Sum(nil)
if serverChecksum != localChecksum {
return job.Error(fmt.Errorf("%q: failed checksum comparison. serverChecksum: %q, localChecksum: %q", remoteName, serverChecksum, localChecksum))
} else {
log.Debugf("imgID: %q, serverChecksum: %q, localChecksum: %q", img.ID, serverChecksum, localChecksum)
}

// So dumb. This should be a call to the image.Image RawJson()
Expand Down Expand Up @@ -302,7 +307,7 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {

// Next, push the manifest
log.Debugf("SUCH MANIFEST %s:%s -- %s", localName, tag, manifestBuf)
err = r.PutV2ImageManifest(localName, tag, bytes.NewReader(manifestBuf), nil)
err = r.PutV2ImageManifest(remoteName, tag, bytes.NewReader(manifestBuf), nil)
if err != nil {
return job.Error(err)
}
Expand Down
4 changes: 4 additions & 0 deletions registry/endpoint.go
Expand Up @@ -41,11 +41,15 @@ func NewEndpoint(hostname string) (*Endpoint, error) {
trimmedHostname string
err error
)
if !strings.HasPrefix(hostname, "http") {
hostname = "https://" + hostname
}
trimmedHostname, endpoint.Version = scanForApiVersion(hostname)
endpoint.URL, err = url.Parse(trimmedHostname)
if err != nil {
return nil, err
}
fmt.Printf("%#v\n", endpoint.URL)
// XXX TESTING ONLY
if drv := os.Getenv("DOCKER_REGISTRY_VERSION"); len(drv) > 0 {
if v, err := strconv.Atoi(drv); err == nil {
Expand Down
5 changes: 4 additions & 1 deletion registry/session_prov.go
Expand Up @@ -31,6 +31,9 @@ func getV2URL(e *Endpoint, routeName string, vars map[string]string) (*url.URL,
return nil, fmt.Errorf("unable to make registry route %q with vars %v: %s", routeName, vars, err)
}

fmt.Println(e.URL.Scheme)
fmt.Println(e.URL.Host)

return &url.URL{
Scheme: e.URL.Scheme,
Host: e.URL.Host,
Expand Down Expand Up @@ -251,7 +254,7 @@ func (r *Session) PutV2ImageManifest(imageName, tagName string, manifestRdr io.R
return err
}
res.Body.Close()
if res.StatusCode != 200 {
if res.StatusCode != 201 {
if res.StatusCode == 401 {
return errLoginRequired
}
Expand Down

0 comments on commit 88d3e14

Please sign in to comment.