Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

always populate service port name #384

Merged
merged 1 commit into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pkg/spec/populators.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ import (

func populateServicePortNames(serviceName string, servicePorts []api_v1.ServicePort) {
// auto populate port names if more than 1 port specified
if len(servicePorts) > 1 {
for i := range servicePorts {
// Only populate if the port name is not already specified
if len(servicePorts[i].Name) == 0 {
servicePorts[i].Name = serviceName + "-" + strconv.FormatInt(int64(servicePorts[i].Port), 10)
}
for i := range servicePorts {
// Only populate if the port name is not already specified
if len(servicePorts[i].Name) == 0 {
servicePorts[i].Name = serviceName + "-" + strconv.FormatInt(int64(servicePorts[i].Port), 10)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/spec/populators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func TestPopulateServicePortNames(t *testing.T) {
},
outputServicePorts: []api_v1.ServicePort{
{
Name: fmt.Sprintf("%v-%v", serviceName, 8080),
Port: 8080,
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/spec/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func TestCreateServices(t *testing.T) {
},
append(make([]runtime.Object, 0), &api_v1.Service{
ObjectMeta: meta_v1.ObjectMeta{Name: "test"},
Spec: api_v1.ServiceSpec{Ports: []api_v1.ServicePort{{Port: 8080}}},
Spec: api_v1.ServiceSpec{Ports: []api_v1.ServicePort{{Port: 8080, Name: "test-8080"}}},
}),
},
}
Expand Down