Skip to content

Commit

Permalink
fixup! Add test for LoadBalancer and ExternalIPs
Browse files Browse the repository at this point in the history
  • Loading branch information
burningalchemist committed Apr 9, 2020
1 parent cde765b commit 01535a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions source/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ func extractLoadBalancerTargets(svc *v1.Service) endpoint.Targets {
externalIPs endpoint.Targets
)


// Create a corresponding endpoint for each configured external entrypoint.
for _, lb := range svc.Status.LoadBalancer.Ingress {
if lb.IP != "" {
Expand All @@ -501,14 +500,14 @@ func extractLoadBalancerTargets(svc *v1.Service) endpoint.Targets {
}

if svc.Spec.ExternalIPs != nil {
for _, ext := range svc.Spec.ExternalIPs {
externalIPs = append(externalIPs, ext)
for _, ext := range svc.Spec.ExternalIPs {
externalIPs = append(externalIPs, ext)
}
}

if len(externalIPs) > 0 {
return externalIPs
}
}

return targets
}
Expand Down
8 changes: 4 additions & 4 deletions source/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,11 @@ func testServiceSourceEndpoints(t *testing.T) {
hostnameAnnotationKey: "foo.example.org.",
},
"",
[]string{"10.2.3.4","11.2.3.4"},
[]string{"10.2.3.4", "11.2.3.4"},
[]string{"1.2.3.4"},
[]string{},
[]*endpoint.Endpoint{
{DNSName: "foo.example.org", Targets: endpoint.Targets{"10.2.3.4","11.2.3.4"}},
{DNSName: "foo.example.org", Targets: endpoint.Targets{"10.2.3.4", "11.2.3.4"}},
},
false,
},
Expand Down Expand Up @@ -1144,8 +1144,8 @@ func testServiceSourceEndpoints(t *testing.T) {

service := &v1.Service{
Spec: v1.ServiceSpec{
Type: tc.svcType,
ClusterIP: tc.clusterIP,
Type: tc.svcType,
ClusterIP: tc.clusterIP,
ExternalIPs: tc.externalIPs,
},
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 01535a4

Please sign in to comment.