Skip to content

Commit 2635232

Browse files
authored
Merge branch 'main' into billy/feat/req-ipc-allow-builder-ip
2 parents d4417b6 + 06e4011 commit 2635232

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

pkg/buildx/bake/bake.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,8 @@ func setPushOverride(outputs []*buildflags.ExportEntry, push bool) []*buildflags
12861286
outputs[i] = output
12871287
}
12881288
}
1289+
1290+
return outputs
12891291
}
12901292

12911293
for i, output := range outputs {

pkg/load/cli.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
depotbuild "github.com/depot/cli/pkg/build"
88
"github.com/docker/buildx/build"
9+
"github.com/docker/buildx/util/platformutil"
910
"github.com/docker/buildx/util/progress"
1011
"github.com/moby/buildkit/client"
1112
)
@@ -79,6 +80,13 @@ func WithDepotImagePull(buildOpts map[string]build.Options, loadOpts DepotLoadOp
7980
pullOpt.Username = &loadOpts.PullInfo.Username
8081
pullOpt.Password = &loadOpts.PullInfo.Password
8182
pullOpt.ServerAddress = &serverAddress
83+
84+
platforms := platformutil.Format(buildOpt.Platforms)
85+
// only specify a platform to pull when a single platform is used
86+
if len(platforms) == 1 {
87+
platform := platforms[0]
88+
pullOpt.Platform = &platform
89+
}
8290
}
8391

8492
toPull[target] = pullOpt

pkg/registry/cli.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,24 @@ func WithDepotSave(buildOpts map[string]buildx.Options, opts SaveOptions) map[st
3535
}
3636
}
3737

38+
exports := deepCloneExports(buildOpt.Exports)
39+
3840
for _, i := range imageExportIndices {
39-
_, ok := buildOpt.Exports[i].Attrs["push"]
41+
_, ok := exports[i].Attrs["push"]
4042
hadPush = hadPush || ok
41-
buildOpt.Exports[i].Attrs["push"] = "true"
43+
exports[i].Attrs["push"] = "true"
4244
}
4345

4446
if len(imageExportIndices) == 0 {
4547
exportImage := client.ExportEntry{
4648
Type: "image",
4749
Attrs: map[string]string{"push": "true"},
4850
}
49-
buildOpt.Exports = append(buildOpt.Exports, exportImage)
51+
exports = append(exports, exportImage)
5052
}
5153

54+
buildOpt.Exports = exports
55+
5256
additionalTags := slices.Clone(opts.AdditionalTags)
5357
for i, tag := range additionalTags {
5458
if opts.AddTargetSuffix {
@@ -68,3 +72,23 @@ func WithDepotSave(buildOpts map[string]buildx.Options, opts SaveOptions) map[st
6872

6973
return buildOpts
7074
}
75+
76+
func deepCloneExports(original []client.ExportEntry) []client.ExportEntry {
77+
if original == nil {
78+
return nil
79+
}
80+
81+
exports := make([]client.ExportEntry, len(original))
82+
for i := range original {
83+
clone := original[i]
84+
// Attrs is the only field with references
85+
clone.Attrs = make(map[string]string, len(original[i].Attrs))
86+
for k, v := range original[i].Attrs {
87+
clone.Attrs[k] = v
88+
}
89+
90+
exports[i] = clone
91+
}
92+
93+
return exports
94+
}

0 commit comments

Comments
 (0)