exporter: reuse exptypes constants

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-07-12 18:02:36 -07:00
parent 0e122d46eb
commit 8c065401f2
3 changed files with 18 additions and 18 deletions

View File

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

View File

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

View File

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