mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +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/driver"
|
||||||
"github.com/docker/buildx/util/imagetools"
|
"github.com/docker/buildx/util/imagetools"
|
||||||
"github.com/docker/buildx/util/progress"
|
"github.com/docker/buildx/util/progress"
|
||||||
|
"github.com/docker/buildx/util/resolver"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"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))
|
wg.Add(len(dps))
|
||||||
|
|
||||||
var pushNames string
|
var pushNames string
|
||||||
|
var insecurePush bool
|
||||||
|
|
||||||
eg.Go(func() (err error) {
|
eg.Go(func() (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -732,9 +734,25 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, do
|
|||||||
imageopt = drivers[dp.driverIndex].ImageOpt
|
imageopt = drivers[dp.driverIndex].ImageOpt
|
||||||
break
|
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)
|
itpull := imagetools.New(imageopt)
|
||||||
|
|
||||||
names := strings.Split(pushNames, ",")
|
|
||||||
dt, desc, err := itpull.Combine(ctx, names[0], descs)
|
dt, desc, err := itpull.Combine(ctx, names[0], descs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -790,6 +808,9 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, do
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if ok, _ := strconv.ParseBool(e.Attrs["registry.insecure"]); ok {
|
||||||
|
insecurePush = true
|
||||||
|
}
|
||||||
e.Attrs["name"] = names
|
e.Attrs["name"] = names
|
||||||
e.Attrs["push-by-digest"] = "true"
|
e.Attrs["push-by-digest"] = "true"
|
||||||
so.Exports[i].Attrs = e.Attrs
|
so.Exports[i].Attrs = e.Attrs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user