Skip to content

Commit 01e731b

Browse files
authored
Merge pull request #3250 from tonistiigi/v0.25.0-rc2-picks
[v0.25] v0.25.0-rc2 cherry-picks
2 parents 32e9bfc + e785cc4 commit 01e731b

File tree

13 files changed

+99
-45
lines changed

13 files changed

+99
-45
lines changed

bake/compose.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,8 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
125125
extraHosts := map[string]*string{}
126126
if s.Build.ExtraHosts != nil {
127127
for k, v := range s.Build.ExtraHosts {
128-
for _, ip := range v {
129-
vv := ip
130-
extraHosts[k] = &vv
131-
}
128+
vv := strings.Join(v, ",")
129+
extraHosts[k] = &vv
132130
}
133131
}
134132

bake/compose_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ services:
3434
- type=local,dest=path/to/cache
3535
extra_hosts:
3636
- "somehost:162.242.195.82"
37+
- "somehost:162.242.195.83"
3738
- "myhostv6:::1"
3839
ssh:
3940
- key=/path/to/key
@@ -79,7 +80,7 @@ secrets:
7980
require.Equal(t, ptrstr("123"), c.Targets[1].Args["buildno"])
8081
require.Equal(t, []string{"type=local,src=path/to/cache"}, stringify(c.Targets[1].CacheFrom))
8182
require.Equal(t, []string{"type=local,dest=path/to/cache"}, stringify(c.Targets[1].CacheTo))
82-
require.Equal(t, map[string]*string{"myhostv6": ptrstr("::1"), "somehost": ptrstr("162.242.195.82")}, c.Targets[1].ExtraHosts)
83+
require.Equal(t, map[string]*string{"myhostv6": ptrstr("::1"), "somehost": ptrstr("162.242.195.82,162.242.195.83")}, c.Targets[1].ExtraHosts)
8384
require.Equal(t, "none", *c.Targets[1].NetworkMode)
8485
require.Equal(t, []string{"default", "key=/path/to/key"}, stringify(c.Targets[1].SSH))
8586
require.Equal(t, []string{

build/utils.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,30 @@ func toBuildkitExtraHosts(ctx context.Context, inp []string, nodeDriver *driver.
7777
}
7878
// If the IP Address is a "host-gateway", replace this value with the
7979
// IP address provided by the worker's label.
80+
var ips []string
8081
if ip == mobyHostGatewayName {
8182
hgip, err := nodeDriver.HostGatewayIP(ctx)
8283
if err != nil {
8384
return "", errors.Wrap(err, "unable to derive the IP value for host-gateway")
8485
}
85-
ip = hgip.String()
86+
ips = append(ips, hgip.String())
8687
} else {
87-
// If the address is enclosed in square brackets, extract it (for IPv6, but
88-
// permit it for IPv4 as well; we don't know the address family here, but it's
89-
// unambiguous).
90-
if len(ip) > 2 && ip[0] == '[' && ip[len(ip)-1] == ']' {
91-
ip = ip[1 : len(ip)-1]
92-
}
93-
if net.ParseIP(ip) == nil {
94-
return "", errors.Errorf("invalid host %s", h)
88+
for _, v := range strings.Split(ip, ",") {
89+
// If the address is enclosed in square brackets, extract it
90+
// (for IPv6, but permit it for IPv4 as well; we don't know the
91+
// address family here, but it's unambiguous).
92+
if len(v) > 2 && v[0] == '[' && v[len(v)-1] == ']' {
93+
v = v[1 : len(v)-1]
94+
}
95+
if net.ParseIP(v) == nil {
96+
return "", errors.Errorf("invalid host %s", h)
97+
}
98+
ips = append(ips, v)
9599
}
96100
}
97-
hosts = append(hosts, host+"="+ip)
101+
for _, v := range ips {
102+
hosts = append(hosts, host+"="+v)
103+
}
98104
}
99105
return strings.Join(hosts, ","), nil
100106
}

build/utils_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ func TestToBuildkitExtraHosts(t *testing.T) {
7272
doc: "IPv6 localhost, non-canonical, eq sep",
7373
input: []string{`ipv6local=0:0:0:0:0:0:0:1`},
7474
},
75+
{
76+
doc: "Multi IPs",
77+
input: []string{`myhost=162.242.195.82,162.242.195.83`},
78+
expectedOut: `myhost=162.242.195.82,myhost=162.242.195.83`,
79+
},
7580
{
7681
doc: "IPv6 localhost, non-canonical, eq sep, brackets",
7782
input: []string{`ipv6local=[0:0:0:0:0:0:0:1]`},

commands/bake.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba
162162
attributes := bakeMetricAttributes(dockerCli, driverType, url, cmdContext, targets, &in)
163163

164164
progressMode := progressui.DisplayMode(cFlags.progress)
165+
165166
var printer *progress.Printer
167+
defer func() {
168+
if printer != nil {
169+
printer.Wait()
170+
}
171+
}()
166172

167173
makePrinter := func() error {
168174
var err error

commands/history/inspect.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,23 +426,32 @@ workers0:
426426
}
427427

428428
provIndex := slices.IndexFunc(attachments, func(a attachment) bool {
429-
return descrType(a.descr) == slsa02.PredicateSLSAProvenance
429+
return strings.HasPrefix(descrType(a.descr), "https://slsa.dev/provenance/")
430430
})
431431
if provIndex != -1 {
432432
prov := attachments[provIndex]
433+
predType := descrType(prov.descr)
433434
dt, err := content.ReadBlob(ctx, store, prov.descr)
434435
if err != nil {
435436
return errors.Errorf("failed to read provenance %s: %v", prov.descr.Digest, err)
436437
}
437-
var pred provenancetypes.ProvenancePredicateSLSA02
438-
if err := json.Unmarshal(dt, &pred); err != nil {
438+
var pred *provenancetypes.ProvenancePredicateSLSA1
439+
if predType == slsa02.PredicateSLSAProvenance {
440+
var pred02 *provenancetypes.ProvenancePredicateSLSA02
441+
if err := json.Unmarshal(dt, &pred02); err != nil {
442+
return errors.Errorf("failed to unmarshal provenance %s: %v", prov.descr.Digest, err)
443+
}
444+
pred = provenancetypes.ConvertSLSA02ToSLSA1(pred02)
445+
} else if err := json.Unmarshal(dt, &pred); err != nil {
439446
return errors.Errorf("failed to unmarshal provenance %s: %v", prov.descr.Digest, err)
440447
}
441-
for _, m := range pred.Materials {
442-
out.Materials = append(out.Materials, materialOutput{
443-
URI: m.URI,
444-
Digests: digestSetToDigests(m.Digest),
445-
})
448+
if pred != nil {
449+
for _, m := range pred.BuildDefinition.ResolvedDependencies {
450+
out.Materials = append(out.Materials, materialOutput{
451+
URI: m.URI,
452+
Digests: digestSetToDigests(m.Digest),
453+
})
454+
}
446455
}
447456
}
448457

commands/history/inspect_attachment.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/docker/cli/cli/command"
1212
intoto "github.com/in-toto/in-toto-golang/in_toto"
1313
slsa02 "github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/v0.2"
14+
slsa1 "github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/v1"
1415
"github.com/opencontainers/go-digest"
1516
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
1617
"github.com/pkg/errors"
@@ -76,25 +77,30 @@ func runAttachment(ctx context.Context, dockerCli command.Cli, opts attachmentOp
7677
return err
7778
}
7879

79-
typ := opts.typ
80-
switch typ {
80+
types := make(map[string]struct{})
81+
switch opts.typ {
8182
case "index":
82-
typ = ocispecs.MediaTypeImageIndex
83+
types[ocispecs.MediaTypeImageIndex] = struct{}{}
8384
case "manifest":
84-
typ = ocispecs.MediaTypeImageManifest
85+
types[ocispecs.MediaTypeImageManifest] = struct{}{}
8586
case "image":
86-
typ = ocispecs.MediaTypeImageConfig
87+
types[ocispecs.MediaTypeImageConfig] = struct{}{}
8788
case "provenance":
88-
typ = slsa02.PredicateSLSAProvenance
89+
types[slsa1.PredicateSLSAProvenance] = struct{}{}
90+
types[slsa02.PredicateSLSAProvenance] = struct{}{}
8991
case "sbom":
90-
typ = intoto.PredicateSPDX
92+
types[intoto.PredicateSPDX] = struct{}{}
93+
default:
94+
if opts.typ != "" {
95+
types[opts.typ] = struct{}{}
96+
}
9197
}
9298

9399
for _, a := range attachments {
94100
if opts.platform != "" && (a.platform == nil || platforms.FormatAll(*a.platform) != opts.platform) {
95101
continue
96102
}
97-
if typ != "" && descrType(a.descr) != typ {
103+
if _, ok := types[descrType(a.descr)]; opts.typ != "" && !ok {
98104
continue
99105
}
100106
ra, err := store.ReaderAt(ctx, a.descr)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/hashicorp/hcl/v2 v2.23.0
2929
github.com/in-toto/in-toto-golang v0.9.0
3030
github.com/mitchellh/hashstructure/v2 v2.0.2
31-
github.com/moby/buildkit v0.23.0-rc1
31+
github.com/moby/buildkit v0.23.0-rc2
3232
github.com/moby/go-archive v0.1.0
3333
github.com/moby/sys/atomicwriter v0.1.0
3434
github.com/moby/sys/mountinfo v0.7.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX
250250
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
251251
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
252252
github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
253-
github.com/moby/buildkit v0.23.0-rc1 h1:RIAEITsycLbXUt//rEPEfZUFnKUcm1cvpuWOfOidiWU=
254-
github.com/moby/buildkit v0.23.0-rc1/go.mod h1:v5jMDvQgUyidk3wu3NvVAAd5JJo83nfet9Gf/o0+EAQ=
253+
github.com/moby/buildkit v0.23.0-rc2 h1:LJIyp/w3/yzVKXngKnkvBw3mvsoE2HkvjAk4+RIBcX8=
254+
github.com/moby/buildkit v0.23.0-rc2/go.mod h1:v5jMDvQgUyidk3wu3NvVAAd5JJo83nfet9Gf/o0+EAQ=
255255
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
256256
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
257257
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=

tests/bake.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,11 +2167,14 @@ func testBakeExtraHosts(t *testing.T, sb integration.Sandbox) {
21672167
dockerfile := []byte(`
21682168
FROM busybox
21692169
RUN cat /etc/hosts | grep myhost | grep 1.2.3.4
2170+
RUN cat /etc/hosts | grep myhostmulti | grep 162.242.195.81
2171+
RUN cat /etc/hosts | grep myhostmulti | grep 162.242.195.82
21702172
`)
21712173
bakefile := []byte(`
21722174
target "default" {
21732175
extra-hosts = {
21742176
myhost = "1.2.3.4"
2177+
myhostmulti = "162.242.195.81,162.242.195.82"
21752178
}
21762179
}
21772180
`)

0 commit comments

Comments
 (0)