c8d/save: Don't save name if exported by digest
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
b5f5987959
commit
f51c5e1a5c
1 changed files with 17 additions and 0 deletions
|
@ -108,6 +108,19 @@ func (i *ImageService) ExportImage(ctx context.Context, names []string, outStrea
|
|||
"name": ref,
|
||||
}).Debug("export image")
|
||||
} else {
|
||||
orgTarget := target
|
||||
target.Annotations = make(map[string]string)
|
||||
|
||||
for k, v := range orgTarget.Annotations {
|
||||
switch k {
|
||||
case containerdimages.AnnotationImageName, ocispec.AnnotationRefName:
|
||||
// Strip image name/tag annotations from the descriptor.
|
||||
// Otherwise containerd will use it as name.
|
||||
default:
|
||||
target.Annotations[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
opts = append(opts, archive.WithManifest(target))
|
||||
|
||||
log.G(ctx).WithFields(log.Fields{
|
||||
|
@ -187,6 +200,10 @@ func (i *ImageService) ExportImage(ctx context.Context, names []string, outStrea
|
|||
return refErr
|
||||
}
|
||||
|
||||
// If user exports a specific digest, it shouldn't have a tag.
|
||||
if specificDigestResolved {
|
||||
ref = nil
|
||||
}
|
||||
if err := exportImage(ctx, target, ref); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue