Skip to content

Commit b5f1fca

Browse files
committed
implement priority using API 1.48
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent fa39503 commit b5f1fca

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

go.mod

+6-7
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ require (
1414
github.com/containerd/platforms v0.2.1
1515
github.com/davecgh/go-spew v1.1.1
1616
github.com/distribution/reference v0.6.0
17-
github.com/docker/buildx v0.19.2
18-
github.com/docker/cli v27.4.0+incompatible
17+
github.com/docker/buildx v0.15.1
18+
github.com/docker/cli v27.0.2-0.20250108175711-ff4697d82091+incompatible
1919
github.com/docker/cli-docs-tool v0.8.0
20-
github.com/docker/docker v27.4.0+incompatible
20+
github.com/docker/docker v27.0.2-0.20250109202641-00d1b92d0a47+incompatible
2121
github.com/docker/go-connections v0.5.0
2222
github.com/docker/go-units v0.5.0
2323
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
@@ -29,7 +29,7 @@ require (
2929
github.com/mattn/go-shellwords v1.0.12
3030
github.com/mitchellh/go-ps v1.0.0
3131
github.com/mitchellh/mapstructure v1.5.0
32-
github.com/moby/buildkit v0.18.1
32+
github.com/moby/buildkit v0.18.2
3333
github.com/moby/patternmatcher v0.6.0
3434
github.com/moby/term v0.5.0
3535
github.com/morikuni/aec v1.0.0
@@ -67,6 +67,7 @@ require (
6767
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
6868
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
6969
github.com/Masterminds/semver/v3 v3.2.1 // indirect
70+
github.com/Microsoft/hcsshim v0.11.7 // indirect
7071
github.com/aws/aws-sdk-go-v2 v1.24.1 // indirect
7172
github.com/aws/aws-sdk-go-v2/config v1.26.6 // indirect
7273
github.com/aws/aws-sdk-go-v2/credentials v1.16.16 // indirect
@@ -105,6 +106,7 @@ require (
105106
github.com/go-openapi/swag v0.22.3 // indirect
106107
github.com/go-viper/mapstructure/v2 v2.0.0 // indirect
107108
github.com/gofrs/flock v0.12.1 // indirect
109+
github.com/gogo/googleapis v1.4.1 // indirect
108110
github.com/gogo/protobuf v1.3.2 // indirect
109111
github.com/golang/protobuf v1.5.4 // indirect
110112
github.com/google/gnostic-models v0.6.8 // indirect
@@ -129,7 +131,6 @@ require (
129131
github.com/mattn/go-runewidth v0.0.15 // indirect
130132
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
131133
github.com/miekg/pkcs11 v1.1.1 // indirect
132-
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
133134
github.com/moby/docker-image-spec v1.3.1 // indirect
134135
github.com/moby/locker v1.0.1 // indirect
135136
github.com/moby/spdystream v0.2.0 // indirect
@@ -157,9 +158,7 @@ require (
157158
github.com/secure-systems-lab/go-securesystemslib v0.4.0 // indirect
158159
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b // indirect
159160
github.com/shibumi/go-pathspec v1.3.0 // indirect
160-
github.com/tonistiigi/dchapes-mode v0.0.0-20241001053921-ca0759fec205 // indirect
161161
github.com/tonistiigi/fsutil v0.0.0-20241121093142-31cf1f437184 // indirect
162-
github.com/tonistiigi/go-csvvalue v0.0.0-20240710180619-ddb21b71c0b4 // indirect
163162
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect
164163
github.com/tonistiigi/vt100 v0.0.0-20240514184818-90bafcd6abab // indirect
165164
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect

go.sum

+18-16
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 h1:59M
66
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0/go.mod h1:OahwfttHWG6eJ0clwcfBAHoDI6X/LV/15hx/wlMZSrU=
77
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
88
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
9-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
10-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
9+
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
10+
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
1111
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
1212
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
1313
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
@@ -122,17 +122,22 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
122122
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
123123
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
124124
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
125-
github.com/docker/buildx v0.19.2 h1:2zXzgP2liQKgQ5BiOqMc+wz7hfWgAIMWw5MR6QDG++I=
126-
github.com/docker/buildx v0.19.2/go.mod h1:k4WP+XmGRYL0a7l4RZAI2TqpwhuAuSQ5U/rosRgFmAA=
127-
github.com/docker/cli v27.4.0+incompatible h1:/nJzWkcI1MDMN+U+px/YXnQWJqnu4J+QKGTfD6ptiTc=
128-
github.com/docker/cli v27.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
125+
github.com/docker/buildx v0.15.1 h1:1cO6JIc0rOoC8tlxfXoh1HH1uxaNvYH1q7J7kv5enhw=
126+
github.com/docker/buildx v0.15.1/go.mod h1:16DQgJqoggmadc1UhLaUTPqKtR+PlByN/kyXFdkhFCo=
127+
github.com/docker/buildx v0.19.1-0.20250109164923-16edf5d4aa76 h1:N+S5wLEnQO56lM6h6TcP26FZWxVj05xcVNxTLyUfdEU=
128+
github.com/docker/buildx v0.19.1-0.20250109164923-16edf5d4aa76/go.mod h1:GhIq7DNYr9dld6K5FpDWTLrDM7FxKz3DMgPSObYALwo=
129+
github.com/docker/cli v27.4.0-rc.2+incompatible h1:A0GZwegDlt2wdt3tpmrUzkVOZmbhvd7i05wPSf7Oo74=
130+
github.com/docker/cli v27.4.0-rc.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
131+
github.com/docker/cli v27.4.1+incompatible h1:VzPiUlRJ/xh+otB75gva3r05isHMo5wXDfPRi5/b4hI=
132+
github.com/docker/cli v27.4.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
129133
github.com/docker/cli-docs-tool v0.8.0 h1:YcDWl7rQJC3lJ7WVZRwSs3bc9nka97QLWfyJQli8yJU=
130134
github.com/docker/cli-docs-tool v0.8.0/go.mod h1:8TQQ3E7mOXoYUs811LiPdUnAhXrcVsBIrW21a5pUbdk=
131135
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
132136
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
133137
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
134-
github.com/docker/docker v27.4.0+incompatible h1:I9z7sQ5qyzO0BfAb9IMOawRkAGxhYsidKiTMcm0DU+A=
135-
github.com/docker/docker v27.4.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
138+
github.com/docker/docker v27.4.0-rc.2+incompatible h1:9OJjVGtelk/zGC3TyKweJ29b9Axzh0s/0vtU4mneumE=
139+
github.com/docker/docker v27.4.0-rc.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
140+
github.com/docker/docker v27.4.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
136141
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
137142
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
138143
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
@@ -186,6 +191,7 @@ github.com/go-viper/mapstructure/v2 v2.0.0 h1:dhn8MZ1gZ0mzeodTG3jt5Vj/o87xZKuNAp
186191
github.com/go-viper/mapstructure/v2 v2.0.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
187192
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
188193
github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0=
194+
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
189195
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
190196
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
191197
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
@@ -304,13 +310,11 @@ github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU=
304310
github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
305311
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
306312
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
307-
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
308-
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
309313
github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
310314
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
311315
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
312-
github.com/moby/buildkit v0.18.1 h1:Iwrz2F/Za2Gjkpwu3aM2LX92AFfJCJe2oNnvGNvh2Rc=
313-
github.com/moby/buildkit v0.18.1/go.mod h1:vCR5CX8NGsPTthTg681+9kdmfvkvqJBXEv71GZe5msU=
316+
github.com/moby/buildkit v0.18.2 h1:l86uBvxh4ntNoUUg3Y0eGTbKg1PbUh6tawJ4Xt75SpQ=
317+
github.com/moby/buildkit v0.18.2/go.mod h1:vCR5CX8NGsPTthTg681+9kdmfvkvqJBXEv71GZe5msU=
314318
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
315319
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
316320
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
@@ -462,8 +466,6 @@ github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4D
462466
github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw=
463467
github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375 h1:QB54BJwA6x8QU9nHY3xJSZR2kX9bgpZekRKGkLTmEXA=
464468
github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375/go.mod h1:xRroudyp5iVtxKqZCrA6n2TLFRBf8bmnjr1UD4x+z7g=
465-
github.com/tonistiigi/dchapes-mode v0.0.0-20241001053921-ca0759fec205 h1:eUk79E1w8yMtXeHSzjKorxuC8qJOnyXQnLaJehxpJaI=
466-
github.com/tonistiigi/dchapes-mode v0.0.0-20241001053921-ca0759fec205/go.mod h1:3Iuxbr0P7D3zUzBMAZB+ois3h/et0shEz0qApgHYGpY=
467469
github.com/tonistiigi/fsutil v0.0.0-20241121093142-31cf1f437184 h1:RgyoSI38Y36zjQaszel/0RAcIehAnjA1B0RiUV9SDO4=
468470
github.com/tonistiigi/fsutil v0.0.0-20241121093142-31cf1f437184/go.mod h1:Dl/9oEjK7IqnjAm21Okx/XIxUCFJzvh+XdVHUlBwXTw=
469471
github.com/tonistiigi/go-csvvalue v0.0.0-20240710180619-ddb21b71c0b4 h1:7I5c2Ig/5FgqkYOh/N87NzoyI9U15qUPXhDD8uCupv8=
@@ -660,7 +662,7 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMm
660662
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
661663
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
662664
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
663-
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
664-
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
665+
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
666+
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
665667
tags.cncf.io/container-device-interface v0.8.0 h1:8bCFo/g9WODjWx3m6EYl3GfUG31eKJbaggyBDxEldRc=
666668
tags.cncf.io/container-device-interface v0.8.0/go.mod h1:Apb7N4VdILW0EVdEMRYXIDVRZfNJZ+kmEUss2kRRQ6Y=

pkg/compose/create.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,11 @@ func (s *composeService) prepareContainerMACAddress(ctx context.Context, service
424424
return macAddress, nil
425425
}
426426

427-
func getAliases(project *types.Project, service types.ServiceConfig, serviceIndex int, networkKey string, useNetworkAliases bool) []string {
427+
func getAliases(project *types.Project, service types.ServiceConfig, serviceIndex int, cfg *types.ServiceNetworkConfig, useNetworkAliases bool) []string {
428428
aliases := []string{getContainerName(project.Name, service, serviceIndex)}
429429
if useNetworkAliases {
430430
aliases = append(aliases, service.Name)
431-
if cfg := service.Networks[networkKey]; cfg != nil {
431+
if cfg != nil {
432432
aliases = append(aliases, cfg.Aliases...)
433433
}
434434
}
@@ -456,7 +456,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi
456456
driverOpts = config.DriverOpts
457457
}
458458
return &network.EndpointSettings{
459-
Aliases: getAliases(p, service, serviceIndex, networkKey, useNetworkAliases),
459+
Aliases: getAliases(p, service, serviceIndex, config, useNetworkAliases),
460460
Links: links,
461461
IPAddress: ipv4Address,
462462
IPv6Gateway: ipv6Address,
@@ -568,8 +568,20 @@ func defaultNetworkSettings(
568568
primaryNetworkEndpoint.MacAddress = service.MacAddress
569569
}
570570
}
571-
572571
endpointsConfig[primaryNetworkMobyNetworkName] = primaryNetworkEndpoint
572+
573+
if versions.GreaterThanOrEqualTo(version, "1.48") {
574+
for _, n := range service.NetworksByPriority() {
575+
cfg := service.Networks[n]
576+
if cfg == nil {
577+
continue
578+
}
579+
endpoint := endpointsConfig[n]
580+
endpoint.GwPriority = cfg.Priority
581+
endpointsConfig[n] = endpoint
582+
}
583+
}
584+
573585
networkConfig := &network.NetworkingConfig{
574586
EndpointsConfig: endpointsConfig,
575587
}

0 commit comments

Comments
 (0)