瀏覽代碼

Merge pull request #45123 from vvoland/c8d-upstream-build-dangling

c8d/builder: Store untagged images as dangling
Sebastiaan van Stijn 2 年之前
父節點
當前提交
1816fb66c7
共有 1 個文件被更改,包括 14 次插入3 次删除
  1. 14 3
      builder/builder-next/exporter/overrides/wrapper.go

+ 14 - 3
builder/builder-next/exporter/overrides/wrapper.go

@@ -7,6 +7,14 @@ import (
 	"github.com/moby/buildkit/exporter"
 )
 
+// TODO(vvoland): Use buildkit consts once they're public
+// https://github.com/moby/buildkit/pull/3694
+const (
+	keyImageName      = "name"
+	keyUnpack         = "unpack"
+	keyDanglingPrefix = "dangling-name-prefix"
+)
+
 // Wraps the containerimage exporter's Resolve method to apply moby-specific
 // overrides to the exporter attributes.
 type imageExporterMobyWrapper struct {
@@ -22,12 +30,15 @@ func (e *imageExporterMobyWrapper) Resolve(ctx context.Context, exporterAttrs ma
 	if exporterAttrs == nil {
 		exporterAttrs = make(map[string]string)
 	}
-	reposAndTags, err := SanitizeRepoAndTags(strings.Split(exporterAttrs["name"], ","))
+	reposAndTags, err := SanitizeRepoAndTags(strings.Split(exporterAttrs[keyImageName], ","))
 	if err != nil {
 		return nil, err
 	}
-	exporterAttrs["name"] = strings.Join(reposAndTags, ",")
-	exporterAttrs["unpack"] = "true"
+	exporterAttrs[keyImageName] = strings.Join(reposAndTags, ",")
+	exporterAttrs[keyUnpack] = "true"
+	if _, has := exporterAttrs[keyDanglingPrefix]; !has {
+		exporterAttrs[keyDanglingPrefix] = "moby-dangling"
+	}
 
 	return e.exp.Resolve(ctx, exporterAttrs)
 }