driver: automatically export image to MobyDriver

Signed-off-by: Tibor Vass <tibor@docker.com>
pull/17/head
Tibor Vass 6 years ago
parent 0788035da8
commit bd7ada6593

@ -51,6 +51,9 @@ func Build(ctx context.Context, drivers []driver.Driver, opt map[string]Options,
pwOld := pw
d := drivers[0]
_, isDefaultMobyDriver := d.(interface {
IsDefaultMobyDriver()
})
c, pw, err := driver.Boot(ctx, d, pw)
if err != nil {
close(pwOld.Status())
@ -75,7 +78,16 @@ func Build(ctx context.Context, drivers []driver.Driver, opt map[string]Options,
FrontendAttrs: map[string]string{},
}
if len(opt.Exports) > 1 {
switch len(opt.Exports) {
case 1:
// valid
case 0:
if isDefaultMobyDriver {
// backwards compat for docker driver only:
// this ensures the build results in a docker image.
opt.Exports = []client.ExportEntry{{Type: "image", Attrs: map[string]string{}}}
}
default:
return nil, errors.Errorf("multiple outputs currently unsupported")
}
@ -100,18 +112,21 @@ func Build(ctx context.Context, drivers []driver.Driver, opt map[string]Options,
if e.Type == "oci" && !d.Features()[driver.OCIExporter] {
return nil, notSupported(d, driver.OCIExporter)
}
if e.Type == "docker" && e.Output != nil && !d.Features()[driver.DockerExporter] {
return nil, notSupported(d, driver.DockerExporter)
if e.Type == "docker" {
if e.Output == nil {
if !isDefaultMobyDriver {
return nil, errors.Errorf("loading to docker currently not implemented, specify dest file or -")
}
e.Type = "image"
} else if !d.Features()[driver.DockerExporter] {
return nil, notSupported(d, driver.DockerExporter)
}
}
if e.Type == "image" {
if _, ok := d.(interface {
IsDefaultMobyDriver()
}); ok {
opt.Exports[i].Type = "moby"
if e.Attrs["push"] != "" {
if ok, _ := strconv.ParseBool(e.Attrs["push"]); ok {
return nil, errors.Errorf("auto-push is currently not implemented for moby driver")
}
if e.Type == "image" && isDefaultMobyDriver {
opt.Exports[i].Type = "moby"
if e.Attrs["push"] != "" {
if ok, _ := strconv.ParseBool(e.Attrs["push"]); ok {
return nil, errors.Errorf("auto-push is currently not implemented for moby driver")
}
}
}

@ -64,8 +64,6 @@ func ParseOutputs(inp []string) ([]client.ExportEntry, error) {
if !ok {
if out.Type != client.ExporterDocker {
dest = "-"
} else {
return nil, errors.Errorf("loading to docker currently not implemented, specify dest file or -")
}
}
if dest == "-" {

Loading…
Cancel
Save