c8d/builder: Store untagged images as dangling

Set `dangling-name-prefix` exporter attribute  to `moby-dangling` which
makes it create an containerd image even when user didn't provide any
name for the new image.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-03-08 14:27:03 +01:00
parent 8f716ca06a
commit af677245fb
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -10,8 +10,9 @@ import (
// TODO(vvoland): Use buildkit consts once they're public
// https://github.com/moby/buildkit/pull/3694
const (
keyImageName = "name"
keyUnpack = "unpack"
keyImageName = "name"
keyUnpack = "unpack"
keyDanglingPrefix = "dangling-name-prefix"
)
// Wraps the containerimage exporter's Resolve method to apply moby-specific
@ -35,6 +36,9 @@ func (e *imageExporterMobyWrapper) Resolve(ctx context.Context, exporterAttrs ma
}
exporterAttrs[keyImageName] = strings.Join(reposAndTags, ",")
exporterAttrs[keyUnpack] = "true"
if _, has := exporterAttrs[keyDanglingPrefix]; !has {
exporterAttrs[keyDanglingPrefix] = "moby-dangling"
}
return e.exp.Resolve(ctx, exporterAttrs)
}