diff --git a/directory/directory_dest.go b/directory/directory_dest.go index e3f91440b..8215c9089 100644 --- a/directory/directory_dest.go +++ b/directory/directory_dest.go @@ -102,6 +102,7 @@ func newImageDestination(sys *types.SystemContext, ref dirReference) (private.Im PropertyMethodsInitialize: impl.PropertyMethods(impl.Properties{ SupportedManifestMIMETypes: nil, DesiredLayerCompression: desiredLayerCompression, + AcceptsForeignLayerURLs: false, MustMatchRuntimeOS: false, IgnoresEmbeddedDockerReference: false, // N/A, DockerReference() returns nil. HasThreadSafePutBlob: false, @@ -125,12 +126,6 @@ func (d *dirImageDestination) Close() error { return nil } -// AcceptsForeignLayerURLs returns false iff foreign layers in manifest should be actually -// uploaded to the image destination, true otherwise. -func (d *dirImageDestination) AcceptsForeignLayerURLs() bool { - return false -} - // PutBlobWithOptions writes contents of stream and returns data representing the result. // inputInfo.Digest can be optionally provided if known; if provided, and stream is read to the end without error, the digest MUST match the stream contents. // inputInfo.Size is the expected length of stream, if known. diff --git a/docker/internal/tarfile/dest.go b/docker/internal/tarfile/dest.go index 6ca8d95e8..b36f303a3 100644 --- a/docker/internal/tarfile/dest.go +++ b/docker/internal/tarfile/dest.go @@ -46,6 +46,7 @@ func NewDestination(sys *types.SystemContext, archive *Writer, transportName str manifest.DockerV2Schema2MediaType, // We rely on the types.Image.UpdatedImage schema conversion capabilities. }, DesiredLayerCompression: types.Decompress, + AcceptsForeignLayerURLs: false, MustMatchRuntimeOS: false, IgnoresEmbeddedDockerReference: false, // N/A, we only accept schema2 images where EmbeddedDockerReferenceConflicts() is always false. // The code _is_ actually thread-safe, but apart from computing sizes/digests of layers where @@ -69,12 +70,6 @@ func (d *Destination) AddRepoTags(tags []reference.NamedTagged) { d.repoTags = append(d.repoTags, tags...) } -// AcceptsForeignLayerURLs returns false iff foreign layers in manifest should be actually -// uploaded to the image destination, true otherwise. -func (d *Destination) AcceptsForeignLayerURLs() bool { - return false -} - // PutBlobWithOptions writes contents of stream and returns data representing the result. // inputInfo.Digest can be optionally provided if known; if provided, and stream is read to the end without error, the digest MUST match the stream contents. // inputInfo.Size is the expected length of stream, if known. diff --git a/internal/imagedestination/impl/properties.go b/internal/imagedestination/impl/properties.go index 2843766b6..704812e9a 100644 --- a/internal/imagedestination/impl/properties.go +++ b/internal/imagedestination/impl/properties.go @@ -10,6 +10,9 @@ type Properties struct { SupportedManifestMIMETypes []string // DesiredLayerCompression indicates the kind of compression to apply on layers DesiredLayerCompression types.LayerCompression + // AcceptsForeignLayerURLs is false if foreign layers in manifest should be actually + // uploaded to the image destination, true otherwise. + AcceptsForeignLayerURLs bool // MustMatchRuntimeOS is set to true if the destination can store only images targeted for the current runtime architecture and OS. MustMatchRuntimeOS bool // IgnoresEmbeddedDockerReference is set to true if the destination does not care about Image.EmbeddedDockerReferenceConflicts(), @@ -45,6 +48,12 @@ func (o PropertyMethodsInitialize) DesiredLayerCompression() types.LayerCompress return o.vals.DesiredLayerCompression } +// AcceptsForeignLayerURLs returns false iff foreign layers in manifest should be actually +// uploaded to the image destination, true otherwise. +func (o PropertyMethodsInitialize) AcceptsForeignLayerURLs() bool { + return o.vals.AcceptsForeignLayerURLs +} + // MustMatchRuntimeOS returns true iff the destination can store only images targeted for the current runtime architecture and OS. False otherwise. func (o PropertyMethodsInitialize) MustMatchRuntimeOS() bool { return o.vals.MustMatchRuntimeOS diff --git a/oci/layout/oci_dest.go b/oci/layout/oci_dest.go index ac9ad068e..4face7213 100644 --- a/oci/layout/oci_dest.go +++ b/oci/layout/oci_dest.go @@ -62,6 +62,7 @@ func newImageDestination(sys *types.SystemContext, ref ociReference) (private.Im imgspecv1.MediaTypeImageIndex, }, DesiredLayerCompression: desiredLayerCompression, + AcceptsForeignLayerURLs: true, MustMatchRuntimeOS: false, IgnoresEmbeddedDockerReference: false, // N/A, DockerReference() returns nil. HasThreadSafePutBlob: true, @@ -100,12 +101,6 @@ func (d *ociImageDestination) Close() error { return nil } -// AcceptsForeignLayerURLs returns false iff foreign layers in manifest should be actually -// uploaded to the image destination, true otherwise. -func (d *ociImageDestination) AcceptsForeignLayerURLs() bool { - return true -} - // PutBlobWithOptions writes contents of stream and returns data representing the result. // inputInfo.Digest can be optionally provided if known; if provided, and stream is read to the end without error, the digest MUST match the stream contents. // inputInfo.Size is the expected length of stream, if known. diff --git a/ostree/ostree_dest.go b/ostree/ostree_dest.go index 40cfb9514..ae8a398bd 100644 --- a/ostree/ostree_dest.go +++ b/ostree/ostree_dest.go @@ -94,6 +94,7 @@ func newImageDestination(ref ostreeReference, tmpDirPath string) (private.ImageD PropertyMethodsInitialize: impl.PropertyMethods(impl.Properties{ SupportedManifestMIMETypes: []string{manifest.DockerV2Schema2MediaType}, DesiredLayerCompression: types.PreserveOriginal, + AcceptsForeignLayerURLs: false, MustMatchRuntimeOS: true, IgnoresEmbeddedDockerReference: false, // N/A, DockerReference() returns nil. HasThreadSafePutBlob: false, @@ -127,12 +128,6 @@ func (d *ostreeImageDestination) Close() error { return os.RemoveAll(d.tmpDirPath) } -// AcceptsForeignLayerURLs returns false iff foreign layers in manifest should be actually -// uploaded to the image destination, true otherwise. -func (d *ostreeImageDestination) AcceptsForeignLayerURLs() bool { - return false -} - // PutBlobWithOptions writes contents of stream and returns data representing the result. // inputInfo.Digest can be optionally provided if known; if provided, and stream is read to the end without error, the digest MUST match the stream contents. // inputInfo.Size is the expected length of stream, if known. diff --git a/storage/storage_image.go b/storage/storage_image.go index 54f2d2fa4..e81f0ea9c 100644 --- a/storage/storage_image.go +++ b/storage/storage_image.go @@ -418,6 +418,7 @@ func newImageDestination(sys *types.SystemContext, imageRef storageReference) (* // and need to explicitly ask for it here, so that the layers' MIME // types can be set accordingly. DesiredLayerCompression: types.PreserveOriginal, + AcceptsForeignLayerURLs: false, MustMatchRuntimeOS: true, IgnoresEmbeddedDockerReference: true, // Yes, we want the unmodified manifest HasThreadSafePutBlob: true, @@ -1204,12 +1205,6 @@ func (s *storageImageDestination) PutManifest(ctx context.Context, manifestBlob return nil } -// AcceptsForeignLayerURLs returns false iff foreign layers in the manifest should actually be -// uploaded to the image destination, true otherwise. -func (s *storageImageDestination) AcceptsForeignLayerURLs() bool { - return false -} - // PutSignatures records the image's signatures for committing as a single data blob. func (s *storageImageDestination) PutSignatures(ctx context.Context, signatures [][]byte, instanceDigest *digest.Digest) error { sizes := []int{}