From 0be4868914008956bac99ded17592b5c7f2db302 Mon Sep 17 00:00:00 2001 From: AhmedGrati <48932084+AhmedGrati@users.noreply.github.com> Date: Mon, 28 Aug 2023 13:55:00 +0100 Subject: [PATCH] Fix expose conversion (#1696) * fix: remove hostport from expose conversion Signed-off-by: AhmedGrati * test: update unit tests Signed-off-by: AhmedGrati --------- Signed-off-by: AhmedGrati --- pkg/loader/compose/compose.go | 1 - pkg/loader/compose/compose_test.go | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/loader/compose/compose.go b/pkg/loader/compose/compose.go index 80b8e0b4..97396243 100644 --- a/pkg/loader/compose/compose.go +++ b/pkg/loader/compose/compose.go @@ -288,7 +288,6 @@ func loadPorts(ports []types.ServicePortConfig, expose []string) []kobject.Ports continue } komposePorts = append(komposePorts, kobject.Ports{ - HostPort: cast.ToInt32(portValue), ContainerPort: cast.ToInt32(portValue), HostIP: "", Protocol: strings.ToUpper(protocol), diff --git a/pkg/loader/compose/compose_test.go b/pkg/loader/compose/compose_test.go index 0ba33a36..eb002e11 100644 --- a/pkg/loader/compose/compose_test.go +++ b/pkg/loader/compose/compose_test.go @@ -221,7 +221,7 @@ func TestLoadV3Ports(t *testing.T) { expose: []string{"80", "8080"}, want: []kobject.Ports{ {HostPort: 80, ContainerPort: 80, Protocol: string(api.ProtocolTCP)}, - {HostPort: 8080, ContainerPort: 8080, Protocol: string(api.ProtocolTCP)}, + {ContainerPort: 8080, Protocol: string(api.ProtocolTCP)}, }, }, { @@ -230,7 +230,7 @@ func TestLoadV3Ports(t *testing.T) { expose: []string{"80/udp"}, want: []kobject.Ports{ {HostPort: 80, ContainerPort: 80, Protocol: string(api.ProtocolTCP)}, - {HostPort: 80, ContainerPort: 80, Protocol: string(api.ProtocolUDP)}, + {ContainerPort: 80, Protocol: string(api.ProtocolUDP)}, }, }, } { @@ -347,8 +347,8 @@ func TestLoadPorts(t *testing.T) { want: []kobject.Ports{ {ContainerPort: 80, Protocol: string(api.ProtocolTCP)}, {ContainerPort: 3000, Protocol: string(api.ProtocolTCP)}, - {HostPort: 80, ContainerPort: 80, Protocol: string(api.ProtocolTCP)}, - {HostPort: 8080, ContainerPort: 8080, Protocol: string(api.ProtocolTCP)}, + {ContainerPort: 80, Protocol: string(api.ProtocolTCP)}, + {ContainerPort: 8080, Protocol: string(api.ProtocolTCP)}, }, }, }