Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkg/loader/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,15 @@ func loadPorts(ports []types.ServicePortConfig, expose []string) []kobject.Ports
exist := map[string]bool{}

for _, port := range ports {
protocol := strings.ToUpper(port.Protocol)
// Convert to a kobject struct with ports
komposePorts = append(komposePorts, kobject.Ports{
HostPort: cast.ToInt32(port.Published),
ContainerPort: int32(port.Target),
HostIP: port.HostIP,
Protocol: strings.ToUpper(port.Protocol),
Protocol: protocol,
})
exist[cast.ToString(port.Target)+port.Protocol] = true
exist[cast.ToString(port.Target)+protocol] = true
}

for _, port := range expose {
Expand All @@ -301,13 +302,14 @@ func loadPorts(ports []types.ServicePortConfig, expose []string) []kobject.Ports
protocol = splits[1]
}

protocol = strings.ToUpper(protocol)
if exist[portValue+protocol] {
continue
}
komposePorts = append(komposePorts, kobject.Ports{
ContainerPort: cast.ToInt32(portValue),
HostIP: "",
Protocol: strings.ToUpper(protocol),
Protocol: protocol,
})
}

Expand Down
1 change: 0 additions & 1 deletion pkg/loader/compose/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ func TestLoadPorts(t *testing.T) {
want: []kobject.Ports{
{ContainerPort: 80, Protocol: string(api.ProtocolTCP)},
{ContainerPort: 3000, Protocol: string(api.ProtocolTCP)},
{ContainerPort: 80, Protocol: string(api.ProtocolTCP)},
{ContainerPort: 8080, Protocol: string(api.ProtocolTCP)},
},
},
Expand Down
Loading