core/images: Ignore attestations when traversing children
Before this patch, calling `image.Children` on an image built with BuildKit would produce unnecessary `encountered unknown type application/vnd.in-toto+json; children may not be fetched` debug logs, because the media type is neither a known layer or config type. Make the `image.Children` aware of the attestation layers and don't attempt to traverse them. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
76db0585af
commit
df4d905a6f
@ -369,8 +369,8 @@ func Children(ctx context.Context, provider content.Provider, desc ocispec.Descr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return append([]ocispec.Descriptor{}, index.Manifests...), nil
|
return append([]ocispec.Descriptor{}, index.Manifests...), nil
|
||||||
} else if !IsLayerType(desc.MediaType) && !IsKnownConfig(desc.MediaType) {
|
} else if !IsLayerType(desc.MediaType) && !IsKnownConfig(desc.MediaType) && !IsAttestationType(desc.MediaType) {
|
||||||
// Layers and configs are childless data types and should not be logged.
|
// Layers, configs, and attestations are childless data types and should not be logged.
|
||||||
log.G(ctx).Debugf("encountered unknown type %v; children may not be fetched", desc.MediaType)
|
log.G(ctx).Debugf("encountered unknown type %v; children may not be fetched", desc.MediaType)
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -58,6 +58,9 @@ const (
|
|||||||
|
|
||||||
MediaTypeImageLayerEncrypted = ocispec.MediaTypeImageLayer + "+encrypted"
|
MediaTypeImageLayerEncrypted = ocispec.MediaTypeImageLayer + "+encrypted"
|
||||||
MediaTypeImageLayerGzipEncrypted = ocispec.MediaTypeImageLayerGzip + "+encrypted"
|
MediaTypeImageLayerGzipEncrypted = ocispec.MediaTypeImageLayerGzip + "+encrypted"
|
||||||
|
|
||||||
|
// In-toto attestation
|
||||||
|
MediaTypeInToto = "application/vnd.in-toto+json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DiffCompression returns the compression as defined by the layer diff media
|
// DiffCompression returns the compression as defined by the layer diff media
|
||||||
@ -193,6 +196,16 @@ func IsKnownConfig(mt string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsAttestationType returns true if the media type is an attestation type
|
||||||
|
func IsAttestationType(mt string) bool {
|
||||||
|
switch mt {
|
||||||
|
case MediaTypeInToto:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ChildGCLabels returns the label for a given descriptor to reference it
|
// ChildGCLabels returns the label for a given descriptor to reference it
|
||||||
func ChildGCLabels(desc ocispec.Descriptor) []string {
|
func ChildGCLabels(desc ocispec.Descriptor) []string {
|
||||||
mt := desc.MediaType
|
mt := desc.MediaType
|
||||||
|
Loading…
Reference in New Issue
Block a user