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

Commit

Permalink
Merge pull request #384 from surajssd/populate-service-port-name
Browse files Browse the repository at this point in the history
always populate service port name
  • Loading branch information
kadel committed Oct 26, 2017
2 parents 66e8dc6 + 99f6ba8 commit 3fcdf5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
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

0 comments on commit 3fcdf5d

Please sign in to comment.