Fix expose conversion (#1696)

* fix: remove hostport from expose conversion

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* test: update unit tests

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

---------

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
AhmedGrati 2023-08-28 13:55:00 +01:00 committed by GitHub
parent 0fa1c1e032
commit 0be4868914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -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),

View File

@ -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)},
},
},
}