From 01535a4db09e85cef0e716d7d33cca909eb4e6af Mon Sep 17 00:00:00 2001 From: Sergei Zyubin Date: Thu, 9 Apr 2020 11:43:02 +0200 Subject: [PATCH] fixup! Add test for LoadBalancer and ExternalIPs --- source/service.go | 7 +++---- source/service_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/source/service.go b/source/service.go index d6da53ef24..860b1b7f72 100644 --- a/source/service.go +++ b/source/service.go @@ -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 != "" { @@ -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 } diff --git a/source/service_test.go b/source/service_test.go index 67459894fb..537d694207 100644 --- a/source/service_test.go +++ b/source/service_test.go @@ -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, }, @@ -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{