Skip to content

Commit d51ca07

Browse files
committed
fix(loader): Allows multiple protocols on one port
1 parent 7b93d61 commit d51ca07

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cli/compose/loader/merge.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ func toServicePortConfigsMap(s any) (map[any]any, error) {
116116
}
117117
m := map[any]any{}
118118
for _, p := range ports {
119-
m[p.Published] = p
119+
protocol := "tcp"
120+
if p.Protocol != "" {
121+
protocol = p.Protocol
122+
}
123+
m[fmt.Sprintf("%d%s", p.Published, protocol)] = p
120124
}
121125
return m, nil
122126
}

cli/compose/loader/merge_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,8 @@ func TestLoadMultipleConfigs(t *testing.T) {
848848
"ports": []any{
849849
"8080:80",
850850
"9090:90",
851+
"53:53/tcp",
852+
"53:53/udp",
851853
},
852854
"labels": []any{
853855
"foo=bar",
@@ -925,6 +927,18 @@ func TestLoadMultipleConfigs(t *testing.T) {
925927
},
926928
},
927929
Ports: []types.ServicePortConfig{
930+
{
931+
Mode: "ingress",
932+
Target: 53,
933+
Published: 53,
934+
Protocol: "tcp",
935+
},
936+
{
937+
Mode: "ingress",
938+
Target: 53,
939+
Published: 53,
940+
Protocol: "udp",
941+
},
928942
{
929943
Target: 81,
930944
Published: 8080,

0 commit comments

Comments
 (0)