diff --git a/exporter/containerimage/export.go b/exporter/containerimage/export.go index ec5a6312..cdbe3469 100644 --- a/exporter/containerimage/export.go +++ b/exporter/containerimage/export.go @@ -8,6 +8,7 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/moby/buildkit/exporter" + "github.com/moby/buildkit/exporter/containerimage/exptypes" "github.com/moby/buildkit/session" "github.com/moby/buildkit/util/push" "github.com/pkg/errors" @@ -15,11 +16,10 @@ import ( ) const ( - keyImageName = "name" - keyPush = "push" - keyInsecure = "registry.insecure" - exporterImageConfig = "containerimage.config" - ociTypes = "oci-mediatypes" + keyImageName = "name" + keyPush = "push" + keyInsecure = "registry.insecure" + ociTypes = "oci-mediatypes" ) type Opt struct { @@ -67,7 +67,7 @@ func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exp return nil, errors.Wrapf(err, "non-bool value specified for %s", k) } i.insecure = b - case exporterImageConfig: + case exptypes.ExporterImageConfigKey: i.config = []byte(v) case ociTypes: if v == "" { @@ -102,7 +102,7 @@ func (e *imageExporterInstance) Name() string { func (e *imageExporterInstance) Export(ctx context.Context, src exporter.Source) (map[string]string, error) { ref := src.Ref opt := src.Metadata - if config, ok := opt[exporterImageConfig]; ok { + if config, ok := opt[exptypes.ExporterImageConfigKey]; ok { e.config = config } desc, err := e.opt.ImageWriter.Commit(ctx, ref, e.config, e.ociTypes) diff --git a/exporter/oci/export.go b/exporter/oci/export.go index 5be9d065..70256347 100644 --- a/exporter/oci/export.go +++ b/exporter/oci/export.go @@ -10,6 +10,7 @@ import ( "github.com/docker/distribution/reference" "github.com/moby/buildkit/exporter" "github.com/moby/buildkit/exporter/containerimage" + "github.com/moby/buildkit/exporter/containerimage/exptypes" "github.com/moby/buildkit/session" "github.com/moby/buildkit/session/filesync" "github.com/moby/buildkit/util/dockerexporter" @@ -22,11 +23,10 @@ import ( type ExporterVariant string const ( - exporterImageConfig = "containerimage.config" - keyImageName = "name" - VariantOCI = "oci" - VariantDocker = "docker" - ociTypes = "oci-mediatypes" + keyImageName = "name" + VariantOCI = "oci" + VariantDocker = "docker" + ociTypes = "oci-mediatypes" ) type Opt struct { @@ -62,7 +62,7 @@ func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exp i := &imageExporterInstance{imageExporter: e, caller: caller} for k, v := range opt { switch k { - case exporterImageConfig: + case exptypes.ExporterImageConfigKey: i.config = []byte(v) case keyImageName: parsed, err := reference.ParseNormalizedNamed(v) @@ -108,7 +108,7 @@ func (e *imageExporterInstance) Name() string { func (e *imageExporterInstance) Export(ctx context.Context, src exporter.Source) (map[string]string, error) { ref := src.Ref opt := src.Metadata - if config, ok := opt[exporterImageConfig]; ok { + if config, ok := opt[exptypes.ExporterImageConfigKey]; ok { e.config = config } desc, err := e.opt.ImageWriter.Commit(ctx, ref, e.config, e.ociTypes) diff --git a/frontend/gateway/gateway.go b/frontend/gateway/gateway.go index 068d92e3..e9b984f5 100644 --- a/frontend/gateway/gateway.go +++ b/frontend/gateway/gateway.go @@ -16,6 +16,7 @@ import ( "github.com/moby/buildkit/cache" "github.com/moby/buildkit/client/llb" "github.com/moby/buildkit/executor" + "github.com/moby/buildkit/exporter/containerimage/exptypes" "github.com/moby/buildkit/frontend" pb "github.com/moby/buildkit/frontend/gateway/pb" "github.com/moby/buildkit/identity" @@ -37,9 +38,8 @@ import ( ) const ( - keySource = "source" - keyDevel = "gateway-devel" - exporterImageConfig = "containerimage.config" + keySource = "source" + keyDevel = "gateway-devel" ) func NewGatewayFrontend(w frontend.WorkerInfos) frontend.Frontend { @@ -97,7 +97,7 @@ func (gf *gatewayFrontend) Solve(ctx context.Context, llbBridge frontend.Fronten return nil, errors.Errorf("invalid ref: %T", devRes.Ref.Sys()) } rootFS = workerRef.ImmutableRef - config, ok := devRes.Metadata[exporterImageConfig] + config, ok := devRes.Metadata[exptypes.ExporterImageConfigKey] if ok { if err := json.Unmarshal(config, &img); err != nil { return nil, err