Merge pull request #1775 from dmcgowan/fix-push-different-tags
Update docker pusher check tag
This commit is contained in:
		| @@ -52,7 +52,11 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
| 	case images.MediaTypeDockerSchema2Manifest, images.MediaTypeDockerSchema2ManifestList, | ||||
| 		ocispec.MediaTypeImageManifest, ocispec.MediaTypeImageIndex: | ||||
| 		isManifest = true | ||||
| 		if p.tag == "" { | ||||
| 			existCheck = path.Join("manifests", desc.Digest.String()) | ||||
| 		} else { | ||||
| 			existCheck = path.Join("manifests", p.tag) | ||||
| 		} | ||||
| 	default: | ||||
| 		existCheck = path.Join("blobs", desc.Digest.String()) | ||||
| 	} | ||||
| @@ -71,6 +75,17 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
| 		log.G(ctx).WithError(err).Debugf("Unable to check existence, continuing with push") | ||||
| 	} else { | ||||
| 		if resp.StatusCode == http.StatusOK { | ||||
| 			var exists bool | ||||
| 			if isManifest && p.tag != "" { | ||||
| 				dgstHeader := digest.Digest(resp.Header.Get("Docker-Content-Digest")) | ||||
| 				if dgstHeader == desc.Digest { | ||||
| 					exists = true | ||||
| 				} | ||||
| 			} else { | ||||
| 				exists = true | ||||
| 			} | ||||
|  | ||||
| 			if exists { | ||||
| 				p.tracker.SetStatus(ref, Status{ | ||||
| 					Status: content.Status{ | ||||
| 						Ref: ref, | ||||
| @@ -79,7 +94,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
| 				}) | ||||
| 				return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest) | ||||
| 			} | ||||
| 		if resp.StatusCode != http.StatusNotFound { | ||||
| 		} else if resp.StatusCode != http.StatusNotFound { | ||||
| 			// TODO: log error | ||||
| 			return nil, errors.Errorf("unexpected response: %s", resp.Status) | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Estes
					Phil Estes