Skip to content

Commit

Permalink
Add Imagedestination.impl.Properties.AcceptsForeignLayerURLs
Browse files Browse the repository at this point in the history
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Jul 1, 2022
1 parent 9a2d2f5 commit aa40cc9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 30 deletions.
7 changes: 1 addition & 6 deletions directory/directory_dest.go
Expand Up @@ -102,6 +102,7 @@ func newImageDestination(sys *types.SystemContext, ref dirReference) (types.Imag
PropertyMethodsInitialize: impl.PropertyMethods(impl.Properties{
SupportedManifestMIMETypes: nil,
DesiredLayerCompression: desiredLayerCompression,
AcceptsForeignLayerURLs: false,
MustMatchRuntimeOS: false,
IgnoresEmbeddedDockerReference: false, // N/A, DockerReference() returns nil.
HasThreadSafePutBlob: false,
Expand All @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions docker/internal/tarfile/dest.go
Expand Up @@ -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
Expand All @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions internal/imagedestination/impl/properties.go
Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions oci/layout/oci_dest.go
Expand Up @@ -62,6 +62,7 @@ func newImageDestination(sys *types.SystemContext, ref ociReference) (types.Imag
imgspecv1.MediaTypeImageIndex,
},
DesiredLayerCompression: desiredLayerCompression,
AcceptsForeignLayerURLs: true,
MustMatchRuntimeOS: false,
IgnoresEmbeddedDockerReference: false, // N/A, DockerReference() returns nil.
HasThreadSafePutBlob: true,
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions ostree/ostree_dest.go
Expand Up @@ -94,6 +94,7 @@ func newImageDestination(ref ostreeReference, tmpDirPath string) (types.ImageDes
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,
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions storage/storage_image.go
Expand Up @@ -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,
Expand Down Expand Up @@ -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{}
Expand Down

0 comments on commit aa40cc9

Please sign in to comment.