archive: consistently respect value of WithSkipDockerManifest
It was possible to still export the docker-compatible manifest.json file, if a single platform image (as a standalone manifest) was exported, even if the WithSkipDockerManifest option was explicitly set. To resolve this, we remove all references to skipDockerManifest to, adding it instead to the point-of-writing, simplifying the earlier logic and making it clear exactly when this manifest file should be written. Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
5da7e2c097
commit
4065831652
@ -188,7 +188,7 @@ func Export(ctx context.Context, store content.Provider, writer io.Writer, opts
|
||||
}
|
||||
|
||||
name := desc.Annotations[images.AnnotationImageName]
|
||||
if name != "" && !eo.skipDockerManifest {
|
||||
if name != "" {
|
||||
mt.names = append(mt.names, name)
|
||||
}
|
||||
case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
||||
@ -227,7 +227,6 @@ func Export(ctx context.Context, store content.Provider, writer io.Writer, opts
|
||||
records = append(records, r...)
|
||||
}
|
||||
|
||||
if !eo.skipDockerManifest {
|
||||
if len(manifests) >= 1 {
|
||||
if len(manifests) > 1 {
|
||||
sort.SliceStable(manifests, func(i, j int) bool {
|
||||
@ -247,7 +246,6 @@ func Export(ctx context.Context, store content.Provider, writer io.Writer, opts
|
||||
} else if eo.platform != nil {
|
||||
return fmt.Errorf("no manifest found for platform: %w", errdefs.ErrNotFound)
|
||||
}
|
||||
}
|
||||
resolvedIndex[desc.Digest] = d
|
||||
}
|
||||
if d != "" {
|
||||
@ -262,7 +260,7 @@ func Export(ctx context.Context, store content.Provider, writer io.Writer, opts
|
||||
}
|
||||
}
|
||||
|
||||
if len(dManifests) > 0 {
|
||||
if !eo.skipDockerManifest && len(dManifests) > 0 {
|
||||
tr, err := manifestsRecord(ctx, store, dManifests)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create manifests file: %w", err)
|
||||
|
Loading…
Reference in New Issue
Block a user