mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
build: handle push/load shorthands for multi exporters
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> (cherry picked from commit a03263acf86c9fec127d4365d1e3996205254299)
This commit is contained in:
parent
84913655a8
commit
1861c07eab
@ -72,11 +72,9 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba
|
|||||||
|
|
||||||
overrides := in.overrides
|
overrides := in.overrides
|
||||||
if in.exportPush {
|
if in.exportPush {
|
||||||
if in.exportLoad {
|
overrides = append(overrides, "*.output=type=registry")
|
||||||
return errors.Errorf("push and load may not be set together at the moment")
|
|
||||||
}
|
}
|
||||||
overrides = append(overrides, "*.push=true")
|
if in.exportLoad {
|
||||||
} else if in.exportLoad {
|
|
||||||
overrides = append(overrides, "*.output=type=docker")
|
overrides = append(overrides, "*.output=type=docker")
|
||||||
}
|
}
|
||||||
if cFlags.noCache != nil {
|
if cFlags.noCache != nil {
|
||||||
|
@ -99,39 +99,39 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if in.ExportPush {
|
if in.ExportPush {
|
||||||
if in.ExportLoad {
|
var pushUsed bool
|
||||||
return nil, nil, errors.Errorf("push and load may not be set together at the moment")
|
for i := range outputs {
|
||||||
|
if outputs[i].Type == client.ExporterImage {
|
||||||
|
outputs[i].Attrs["push"] = "true"
|
||||||
|
pushUsed = true
|
||||||
}
|
}
|
||||||
if len(outputs) == 0 {
|
}
|
||||||
outputs = []client.ExportEntry{{
|
if !pushUsed {
|
||||||
Type: "image",
|
outputs = append(outputs, client.ExportEntry{
|
||||||
|
Type: client.ExporterImage,
|
||||||
Attrs: map[string]string{
|
Attrs: map[string]string{
|
||||||
"push": "true",
|
"push": "true",
|
||||||
},
|
},
|
||||||
}}
|
})
|
||||||
} else {
|
|
||||||
switch outputs[0].Type {
|
|
||||||
case "image":
|
|
||||||
outputs[0].Attrs["push"] = "true"
|
|
||||||
default:
|
|
||||||
return nil, nil, errors.Errorf("push and %q output can't be used together", outputs[0].Type)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if in.ExportLoad {
|
if in.ExportLoad {
|
||||||
if len(outputs) == 0 {
|
var loadUsed bool
|
||||||
outputs = []client.ExportEntry{{
|
for i := range outputs {
|
||||||
Type: "docker",
|
if outputs[i].Type == client.ExporterDocker {
|
||||||
Attrs: map[string]string{},
|
if _, ok := outputs[i].Attrs["dest"]; !ok {
|
||||||
}}
|
loadUsed = true
|
||||||
} else {
|
break
|
||||||
switch outputs[0].Type {
|
|
||||||
case "docker":
|
|
||||||
default:
|
|
||||||
return nil, nil, errors.Errorf("load and %q output can't be used together", outputs[0].Type)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !loadUsed {
|
||||||
|
outputs = append(outputs, client.ExportEntry{
|
||||||
|
Type: client.ExporterDocker,
|
||||||
|
Attrs: map[string]string{},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
annotations, err := buildflags.ParseAnnotations(in.Annotations)
|
annotations, err := buildflags.ParseAnnotations(in.Annotations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user