Merge pull request #1775 from dmcgowan/fix-push-different-tags

Update docker pusher check tag
This commit is contained in:
Phil Estes 2017-11-17 08:21:08 -05:00 committed by GitHub
commit 77cb722e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,11 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
case images.MediaTypeDockerSchema2Manifest, images.MediaTypeDockerSchema2ManifestList, case images.MediaTypeDockerSchema2Manifest, images.MediaTypeDockerSchema2ManifestList,
ocispec.MediaTypeImageManifest, ocispec.MediaTypeImageIndex: ocispec.MediaTypeImageManifest, ocispec.MediaTypeImageIndex:
isManifest = true isManifest = true
existCheck = path.Join("manifests", desc.Digest.String()) if p.tag == "" {
existCheck = path.Join("manifests", desc.Digest.String())
} else {
existCheck = path.Join("manifests", p.tag)
}
default: default:
existCheck = path.Join("blobs", desc.Digest.String()) existCheck = path.Join("blobs", desc.Digest.String())
} }
@ -71,15 +75,26 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
log.G(ctx).WithError(err).Debugf("Unable to check existence, continuing with push") log.G(ctx).WithError(err).Debugf("Unable to check existence, continuing with push")
} else { } else {
if resp.StatusCode == http.StatusOK { if resp.StatusCode == http.StatusOK {
p.tracker.SetStatus(ref, Status{ var exists bool
Status: content.Status{ if isManifest && p.tag != "" {
Ref: ref, dgstHeader := digest.Digest(resp.Header.Get("Docker-Content-Digest"))
// TODO: Set updated time? if dgstHeader == desc.Digest {
}, exists = true
}) }
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest) } else {
} exists = true
if resp.StatusCode != http.StatusNotFound { }
if exists {
p.tracker.SetStatus(ref, Status{
Status: content.Status{
Ref: ref,
// TODO: Set updated time?
},
})
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest)
}
} else if resp.StatusCode != http.StatusNotFound {
// TODO: log error // TODO: log error
return nil, errors.Errorf("unexpected response: %s", resp.Status) return nil, errors.Errorf("unexpected response: %s", resp.Status)
} }