mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 08:57:44 +08:00
driver: automatically export image to MobyDriver
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
0788035da8
commit
bd7ada6593
@ -51,6 +51,9 @@ func Build(ctx context.Context, drivers []driver.Driver, opt map[string]Options,
|
|||||||
|
|
||||||
pwOld := pw
|
pwOld := pw
|
||||||
d := drivers[0]
|
d := drivers[0]
|
||||||
|
_, isDefaultMobyDriver := d.(interface {
|
||||||
|
IsDefaultMobyDriver()
|
||||||
|
})
|
||||||
c, pw, err := driver.Boot(ctx, d, pw)
|
c, pw, err := driver.Boot(ctx, d, pw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
close(pwOld.Status())
|
close(pwOld.Status())
|
||||||
@ -75,7 +78,16 @@ func Build(ctx context.Context, drivers []driver.Driver, opt map[string]Options,
|
|||||||
FrontendAttrs: map[string]string{},
|
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")
|
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] {
|
if e.Type == "oci" && !d.Features()[driver.OCIExporter] {
|
||||||
return nil, notSupported(d, driver.OCIExporter)
|
return nil, notSupported(d, driver.OCIExporter)
|
||||||
}
|
}
|
||||||
if e.Type == "docker" && e.Output != nil && !d.Features()[driver.DockerExporter] {
|
if e.Type == "docker" {
|
||||||
return nil, notSupported(d, driver.DockerExporter)
|
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 e.Type == "image" && isDefaultMobyDriver {
|
||||||
if _, ok := d.(interface {
|
opt.Exports[i].Type = "moby"
|
||||||
IsDefaultMobyDriver()
|
if e.Attrs["push"] != "" {
|
||||||
}); ok {
|
if ok, _ := strconv.ParseBool(e.Attrs["push"]); ok {
|
||||||
opt.Exports[i].Type = "moby"
|
return nil, errors.Errorf("auto-push is currently not implemented for moby driver")
|
||||||
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 !ok {
|
||||||
if out.Type != client.ExporterDocker {
|
if out.Type != client.ExporterDocker {
|
||||||
dest = "-"
|
dest = "-"
|
||||||
} else {
|
|
||||||
return nil, errors.Errorf("loading to docker currently not implemented, specify dest file or -")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dest == "-" {
|
if dest == "-" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user