From 909a4493801d4b291f32c66b80d5c487bdba8c86 Mon Sep 17 00:00:00 2001 From: Ben Meier Date: Mon, 26 Feb 2024 15:12:37 +0000 Subject: [PATCH] fix: reduce example change Signed-off-by: Ben Meier --- e2e-tests/resources/outputs/example-04-extras-output.txt | 1 - internal/compose/convert.go | 6 +++--- internal/compose/convert_test.go | 7 +++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/e2e-tests/resources/outputs/example-04-extras-output.txt b/e2e-tests/resources/outputs/example-04-extras-output.txt index 8252de9..aa9224c 100644 --- a/e2e-tests/resources/outputs/example-04-extras-output.txt +++ b/e2e-tests/resources/outputs/example-04-extras-output.txt @@ -4,7 +4,6 @@ services: ports: - target: 80 published: "8000" - protocol: tcp volumes: - type: volume source: data diff --git a/internal/compose/convert.go b/internal/compose/convert.go index 61afafc..c092cd5 100644 --- a/internal/compose/convert.go +++ b/internal/compose/convert.go @@ -44,14 +44,14 @@ func ConvertSpec(spec *score.Workload) (*compose.Project, ExternalVariables, err ports = []compose.ServicePortConfig{} for _, pSpec := range spec.Service.Ports { var pubPort = fmt.Sprintf("%v", pSpec.Port) - var protocol = score.ServicePortProtocolTCP + var protocol string if pSpec.Protocol != nil { - protocol = *pSpec.Protocol + protocol = strings.ToLower(string(*pSpec.Protocol)) } ports = append(ports, compose.ServicePortConfig{ Published: pubPort, Target: uint32(DerefOr(pSpec.TargetPort, pSpec.Port)), - Protocol: strings.ToLower(string(protocol)), + Protocol: protocol, }) } } diff --git a/internal/compose/convert_test.go b/internal/compose/convert_test.go index 4e84ab6..390dfa0 100644 --- a/internal/compose/convert_test.go +++ b/internal/compose/convert_test.go @@ -83,12 +83,11 @@ func TestScoreConvert(t *testing.T) { { Published: "80", Target: 8080, - Protocol: "TCP", }, { Published: "8080", Target: 8080, - Protocol: "UDP", + Protocol: "udp", }, }, }, @@ -200,8 +199,8 @@ func TestScoreConvert(t *testing.T) { "PORT": stringPtr("81"), }, Ports: []compose.ServicePortConfig{ - {Target: 80, Published: "8080", Protocol: "TCP"}, - {Target: 81, Published: "8081", Protocol: "TCP"}, + {Target: 80, Published: "8080"}, + {Target: 81, Published: "8081"}, }, }, {