Skip to content

Commit

Permalink
Use formatting instead of convertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Rodionov committed Dec 12, 2023
1 parent b53f3e0 commit 2cd4885
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pipeline/backend/kubernetes/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package kubernetes

import (
"strconv"
"fmt"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -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)},
})
Expand Down
6 changes: 3 additions & 3 deletions pipeline/backend/kubernetes/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 2cd4885

Please sign in to comment.