mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
build: support insecure export option for multi-node build
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
c62472121b
commit
1cca41b81a
@ -21,6 +21,7 @@ import (
|
||||
"github.com/docker/buildx/driver"
|
||||
"github.com/docker/buildx/util/imagetools"
|
||||
"github.com/docker/buildx/util/progress"
|
||||
"github.com/docker/buildx/util/resolver"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/docker/docker/api/types"
|
||||
@ -686,6 +687,7 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, do
|
||||
wg.Add(len(dps))
|
||||
|
||||
var pushNames string
|
||||
var insecurePush bool
|
||||
|
||||
eg.Go(func() (err error) {
|
||||
defer func() {
|
||||
@ -732,9 +734,25 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, do
|
||||
imageopt = drivers[dp.driverIndex].ImageOpt
|
||||
break
|
||||
}
|
||||
names := strings.Split(pushNames, ",")
|
||||
|
||||
if insecurePush {
|
||||
insecureTrue := true
|
||||
httpTrue := true
|
||||
nn, err := reference.ParseNormalizedNamed(names[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imageopt.RegistryConfig = map[string]resolver.RegistryConfig{
|
||||
reference.Domain(nn): {
|
||||
Insecure: &insecureTrue,
|
||||
PlainHTTP: &httpTrue,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
itpull := imagetools.New(imageopt)
|
||||
|
||||
names := strings.Split(pushNames, ",")
|
||||
dt, desc, err := itpull.Combine(ctx, names[0], descs)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -790,6 +808,9 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, do
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ok, _ := strconv.ParseBool(e.Attrs["registry.insecure"]); ok {
|
||||
insecurePush = true
|
||||
}
|
||||
e.Attrs["name"] = names
|
||||
e.Attrs["push-by-digest"] = "true"
|
||||
so.Exports[i].Attrs = e.Attrs
|
||||
|
Loading…
Reference in New Issue
Block a user