From 41d65cbe471a0bb05c6e5f041694669b23296853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Fri, 9 Mar 2018 16:11:23 +0100 Subject: [PATCH] Drop storageReference.breakDockerReference and storageImageDestination.publicRef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that storageImageDestination.IgnoreEmbeddedDockerReference exists, this hack is no longer needed. Signed-off-by: Miloslav Trmač --- storage/storage_image.go | 17 ++++------------- storage/storage_reference.go | 10 +++------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/storage/storage_image.go b/storage/storage_image.go index 3beb2bb341..982b523660 100644 --- a/storage/storage_image.go +++ b/storage/storage_image.go @@ -51,8 +51,7 @@ type storageImageSource struct { } type storageImageDestination struct { - imageRef storageReference // The reference we'll use to name the image - publicRef storageReference // The reference we return when asked about the name we'll give to the image + imageRef storageReference directory string // Temporary directory where we store blobs until Commit() time nextTempFileID int32 // A counter that we use for computing filenames to assign to blobs manifest []byte // Manifest contents, temporary @@ -244,15 +243,8 @@ func newImageDestination(ctx *types.SystemContext, imageRef storageReference) (* if err != nil { return nil, errors.Wrapf(err, "error creating a temporary directory") } - // Break reading of the reference we're writing, so that copy.Image() won't try to rewrite - // schema1 image manifests to remove embedded references, since that changes the manifest's - // digest, and that makes the image unusable if we subsequently try to access it using a - // reference that mentions the no-longer-correct digest. - publicRef := imageRef - publicRef.breakDockerReference = true // FIXME: this does not change .StringWithinTransport(), but modifies DockerReference() image := &storageImageDestination{ imageRef: imageRef, - publicRef: publicRef, directory: directory, blobDiffIDs: make(map[digest.Digest]digest.Digest), fileSizes: make(map[digest.Digest]int64), @@ -262,11 +254,10 @@ func newImageDestination(ctx *types.SystemContext, imageRef storageReference) (* return image, nil } -// Reference returns a mostly-usable image reference that can't return a DockerReference, to -// avoid triggering logic in copy.Image() that rewrites schema 1 image manifests in order to -// remove image names that they contain which don't match the value we're using. +// Reference returns the reference used to set up this destination. Note that this should directly correspond to user's intent, +// e.g. it should use the public hostname instead of the result of resolving CNAMEs or following redirects. func (s storageImageDestination) Reference() types.ImageReference { - return s.publicRef + return s.imageRef } // Close cleans up the temporary directory. diff --git a/storage/storage_reference.go b/storage/storage_reference.go index d982a5044f..440c13eec7 100644 --- a/storage/storage_reference.go +++ b/storage/storage_reference.go @@ -17,10 +17,9 @@ import ( // where an image is, or would be, kept. // Either "named" or "id" must be set. type storageReference struct { - transport storageTransport - named reference.Named // may include a tag and/or a digest - id string - breakDockerReference bool // Possibly set by newImageDestination. FIXME: Figure out another way. + transport storageTransport + named reference.Named // may include a tag and/or a digest + id string } func newReference(transport storageTransport, named reference.Named, id string) (*storageReference, error) { @@ -112,9 +111,6 @@ func (s storageReference) Transport() types.ImageTransport { // Return a name with a tag or digest, if we have either, else return it bare. func (s storageReference) DockerReference() reference.Named { - if s.breakDockerReference { - return nil - } return s.named }