diff --git a/pkg/apis/core/v1/helper/helpers.go b/pkg/apis/core/v1/helper/helpers.go index 932e3ac6921..96accbd3f69 100644 --- a/pkg/apis/core/v1/helper/helpers.go +++ b/pkg/apis/core/v1/helper/helpers.go @@ -140,35 +140,6 @@ func IsServiceIPSet(service *v1.Service) bool { return service.Spec.ClusterIP != v1.ClusterIPNone && service.Spec.ClusterIP != "" } -// LoadBalancerStatusEqual evaluates the given load balancers' ingress IP addresses -// and hostnames and returns true if equal or false if otherwise -// TODO: make method on LoadBalancerStatus? -func LoadBalancerStatusEqual(l, r *v1.LoadBalancerStatus) bool { - return ingressSliceEqual(l.Ingress, r.Ingress) -} - -func ingressSliceEqual(lhs, rhs []v1.LoadBalancerIngress) bool { - if len(lhs) != len(rhs) { - return false - } - for i := range lhs { - if !ingressEqual(&lhs[i], &rhs[i]) { - return false - } - } - return true -} - -func ingressEqual(lhs, rhs *v1.LoadBalancerIngress) bool { - if lhs.IP != rhs.IP { - return false - } - if lhs.Hostname != rhs.Hostname { - return false - } - return true -} - // GetAccessModesAsString returns a string representation of an array of access modes. // modes, when present, are always in the same order: RWO,ROX,RWX,RWOP. func GetAccessModesAsString(modes []v1.PersistentVolumeAccessMode) string { diff --git a/pkg/apis/core/v1/helper/helpers_test.go b/pkg/apis/core/v1/helper/helpers_test.go index e691153e4e5..af9a4771fa9 100644 --- a/pkg/apis/core/v1/helper/helpers_test.go +++ b/pkg/apis/core/v1/helper/helpers_test.go @@ -723,86 +723,3 @@ func TestHugePageUnitSizeFromByteSize(t *testing.T) { } } } - -func TestLoadBalancerStatusEqual(t *testing.T) { - - testCases := []struct { - left *v1.LoadBalancerStatus - right *v1.LoadBalancerStatus - name string - expectVal bool - }{{ - name: "left equals right", - left: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.1", - Hostname: "host1", - }}, - }, - right: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.1", - Hostname: "host1", - }}, - }, - expectVal: true, - }, { - name: "length of LoadBalancerIngress slice is not equal", - left: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.1", - Hostname: "host1", - }, { - IP: "1.1.1.2", - Hostname: "host1", - }}, - }, - right: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.1", - Hostname: "host1", - }}, - }, - expectVal: false, - }, { - name: "LoadBalancerIngress ip is not equal", - left: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.2", - Hostname: "host1", - }}, - }, - right: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.1", - Hostname: "host1", - }}, - }, - expectVal: false, - }, { - name: "LoadBalancerIngress hostname is not equal", - left: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.1", - Hostname: "host2", - }}, - }, - right: &v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{{ - IP: "1.1.1.1", - Hostname: "host1", - }}, - }, - expectVal: false, - }} - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - v := LoadBalancerStatusEqual(tc.left, tc.right) - if v != tc.expectVal { - t.Errorf("test %s failed. left input=%v, right input=%v, Got %v but expected %v", - tc.name, tc.left, tc.right, v, tc.expectVal) - } - }) - } -}