Skip to content

Commit

Permalink
fix network aliasses merge logic to conform to docker compose v1
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Dec 15, 2022
1 parent 999ce24 commit b9ad533
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion loader/merge.go
Expand Up @@ -330,7 +330,6 @@ func mergeUlimitsConfig(dst, src reflect.Value) error {
// nolint: unparam
func mergeServiceNetworkConfig(dst, src reflect.Value) error {
if src.Interface() != reflect.Zero(reflect.TypeOf(src.Interface())).Interface() {
dst.Elem().FieldByName("Aliases").Set(src.Elem().FieldByName("Aliases"))
if ipv4 := src.Elem().FieldByName("Ipv4Address").Interface().(string); ipv4 != "" {
dst.Elem().FieldByName("Ipv4Address").SetString(ipv4)
}
Expand Down
8 changes: 4 additions & 4 deletions loader/merge_test.go
Expand Up @@ -816,7 +816,7 @@ func TestLoadMultipleServiceNetworks(t *testing.T) {
},
expected: map[string]*types.ServiceNetworkConfig{
"net1": {
Aliases: []string{"alias2", "alias3"},
Aliases: []string{"alias1", "alias2", "alias3"},
},
"net2": nil,
"net3": {},
Expand Down Expand Up @@ -1117,7 +1117,7 @@ func TestMergeServiceNetworkConfig(t *testing.T) {
},
}
base := map[string]*types.ServiceNetworkConfig{
"override-aliases": {
"merge-aliases": {
Aliases: []string{"100", "101"},
Ipv4Address: "127.0.0.1",
Ipv6Address: "0:0:0:0:0:0:0:1",
Expand Down Expand Up @@ -1146,8 +1146,8 @@ func TestMergeServiceNetworkConfig(t *testing.T) {
t,
base,
map[string]*types.ServiceNetworkConfig{
"override-aliases": {
Aliases: []string{"110", "111"},
"merge-aliases": {
Aliases: []string{"100", "101", "110", "111"},
Ipv4Address: "127.0.1.1",
Ipv6Address: "0:0:0:0:0:0:1:1",
},
Expand Down

0 comments on commit b9ad533

Please sign in to comment.