mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
remove unused function LoadBalancerStatusEqual
It is duplicated in the cloud provider package, and is only used there for the service load balancer controller.
This commit is contained in:
parent
f28b8fee7f
commit
59adf3f833
@ -140,35 +140,6 @@ func IsServiceIPSet(service *v1.Service) bool {
|
|||||||
return service.Spec.ClusterIP != v1.ClusterIPNone && service.Spec.ClusterIP != ""
|
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.
|
// GetAccessModesAsString returns a string representation of an array of access modes.
|
||||||
// modes, when present, are always in the same order: RWO,ROX,RWX,RWOP.
|
// modes, when present, are always in the same order: RWO,ROX,RWX,RWOP.
|
||||||
func GetAccessModesAsString(modes []v1.PersistentVolumeAccessMode) string {
|
func GetAccessModesAsString(modes []v1.PersistentVolumeAccessMode) string {
|
||||||
|
@ -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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user