Browse Source

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>
Paweł Gronowski 2 years ago
parent
commit
af677245fb
1 changed files with 6 additions and 2 deletions
  1. 6 2
      builder/builder-next/exporter/overrides/wrapper.go

+ 6 - 2
builder/builder-next/exporter/overrides/wrapper.go

@@ -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)
 }