From 2cd48855a6aa801b08d3667f8b90e33f53b7c929 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Tue, 12 Dec 2023 17:23:05 +0100 Subject: [PATCH] Use formatting instead of convertion --- pipeline/backend/kubernetes/service.go | 4 ++-- pipeline/backend/kubernetes/service_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pipeline/backend/kubernetes/service.go b/pipeline/backend/kubernetes/service.go index db4c66a441d..b1233f0567e 100644 --- a/pipeline/backend/kubernetes/service.go +++ b/pipeline/backend/kubernetes/service.go @@ -15,7 +15,7 @@ package kubernetes import ( - "strconv" + "fmt" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -26,7 +26,7 @@ func Service(namespace, name string, ports []uint16) (*v1.Service, error) { var svcPorts []v1.ServicePort for _, port := range ports { svcPorts = append(svcPorts, v1.ServicePort{ - Name: strconv.FormatUint(uint64(port), 10), + Name: fmt.Sprintf("port-%d", port), Port: int32(port), TargetPort: intstr.IntOrString{IntVal: int32(port)}, }) diff --git a/pipeline/backend/kubernetes/service_test.go b/pipeline/backend/kubernetes/service_test.go index 46b3a7d89c4..b23017b3fc2 100644 --- a/pipeline/backend/kubernetes/service_test.go +++ b/pipeline/backend/kubernetes/service_test.go @@ -32,17 +32,17 @@ func TestService(t *testing.T) { "spec": { "ports": [ { - "name": "1", + "name": "port-1", "port": 1, "targetPort": 1 }, { - "name": "2", + "name": "port-2", "port": 2, "targetPort": 2 }, { - "name": "3", + "name": "port-3", "port": 3, "targetPort": 3 }