Bump client-go to remove dependence on go-autorest dependency (#9488)
* deps: bump k8s dependencies to remove go-autorest * fix: update use of apiv1.LoadBalancerIngress Due to changes in the Kubernetes API, we needed to switch to using v1.IngressLoadBalancerIngress instead of apiv1.LoadBalancerIngress. The struct is otherwise identical despite the name change. * fix ingress status test cases Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com> Signed-off-by: Ismayil Mirzali <ismayilmirzeli@gmail.com> Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com> Signed-off-by: Ismayil Mirzali <ismayilmirzeli@gmail.com> Co-authored-by: Jintao Zhang <zhangjintao9020@gmail.com>
This commit is contained in:
parent
da98c744b9
commit
fe2e713f42
5 changed files with 114 additions and 156 deletions
|
|
@ -19,6 +19,7 @@ package status
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
v1 "k8s.io/api/networking/v1"
|
||||
"net"
|
||||
"regexp"
|
||||
"sort"
|
||||
|
|
@ -128,7 +129,7 @@ func (s statusSync) Shutdown() {
|
|||
}
|
||||
|
||||
klog.InfoS("removing value from ingress status", "address", addrs)
|
||||
s.updateStatus([]apiv1.LoadBalancerIngress{})
|
||||
s.updateStatus([]v1.IngressLoadBalancerIngress{})
|
||||
}
|
||||
|
||||
func (s *statusSync) sync(key interface{}) error {
|
||||
|
|
@ -160,21 +161,21 @@ func NewStatusSyncer(config Config) Syncer {
|
|||
return st
|
||||
}
|
||||
|
||||
func nameOrIPToLoadBalancerIngress(nameOrIP string) apiv1.LoadBalancerIngress {
|
||||
func nameOrIPToLoadBalancerIngress(nameOrIP string) v1.IngressLoadBalancerIngress {
|
||||
if net.ParseIP(nameOrIP) != nil {
|
||||
return apiv1.LoadBalancerIngress{IP: nameOrIP}
|
||||
return v1.IngressLoadBalancerIngress{IP: nameOrIP}
|
||||
}
|
||||
|
||||
return apiv1.LoadBalancerIngress{Hostname: nameOrIP}
|
||||
return v1.IngressLoadBalancerIngress{Hostname: nameOrIP}
|
||||
}
|
||||
|
||||
// runningAddresses returns a list of IP addresses and/or FQDN where the
|
||||
// ingress controller is currently running
|
||||
func (s *statusSync) runningAddresses() ([]apiv1.LoadBalancerIngress, error) {
|
||||
func (s *statusSync) runningAddresses() ([]v1.IngressLoadBalancerIngress, error) {
|
||||
if s.PublishStatusAddress != "" {
|
||||
re := regexp.MustCompile(`,\s*`)
|
||||
multipleAddrs := re.Split(s.PublishStatusAddress, -1)
|
||||
addrs := make([]apiv1.LoadBalancerIngress, len(multipleAddrs))
|
||||
addrs := make([]v1.IngressLoadBalancerIngress, len(multipleAddrs))
|
||||
for i, addr := range multipleAddrs {
|
||||
addrs[i] = nameOrIPToLoadBalancerIngress(addr)
|
||||
}
|
||||
|
|
@ -193,7 +194,7 @@ func (s *statusSync) runningAddresses() ([]apiv1.LoadBalancerIngress, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
addrs := make([]apiv1.LoadBalancerIngress, 0)
|
||||
addrs := make([]v1.IngressLoadBalancerIngress, 0)
|
||||
for i := range pods.Items {
|
||||
pod := pods.Items[i]
|
||||
// only Running pods are valid
|
||||
|
|
@ -250,7 +251,7 @@ func (s *statusSync) isRunningMultiplePods() bool {
|
|||
|
||||
// standardizeLoadBalancerIngresses sorts the list of loadbalancer by
|
||||
// IP
|
||||
func standardizeLoadBalancerIngresses(lbi []apiv1.LoadBalancerIngress) []apiv1.LoadBalancerIngress {
|
||||
func standardizeLoadBalancerIngresses(lbi []v1.IngressLoadBalancerIngress) []v1.IngressLoadBalancerIngress {
|
||||
sort.SliceStable(lbi, func(a, b int) bool {
|
||||
return lbi[a].IP < lbi[b].IP
|
||||
})
|
||||
|
|
@ -259,7 +260,7 @@ func standardizeLoadBalancerIngresses(lbi []apiv1.LoadBalancerIngress) []apiv1.L
|
|||
}
|
||||
|
||||
// updateStatus changes the status information of Ingress rules
|
||||
func (s *statusSync) updateStatus(newIngressPoint []apiv1.LoadBalancerIngress) {
|
||||
func (s *statusSync) updateStatus(newIngressPoint []v1.IngressLoadBalancerIngress) {
|
||||
ings := s.IngressLister.ListIngresses()
|
||||
|
||||
p := pool.NewLimited(10)
|
||||
|
|
@ -283,7 +284,7 @@ func (s *statusSync) updateStatus(newIngressPoint []apiv1.LoadBalancerIngress) {
|
|||
batch.WaitAll()
|
||||
}
|
||||
|
||||
func runUpdate(ing *ingress.Ingress, status []apiv1.LoadBalancerIngress,
|
||||
func runUpdate(ing *ingress.Ingress, status []v1.IngressLoadBalancerIngress,
|
||||
client clientset.Interface) pool.WorkFunc {
|
||||
return func(wu pool.WorkUnit) (interface{}, error) {
|
||||
if wu.IsCancelled() {
|
||||
|
|
@ -307,7 +308,7 @@ func runUpdate(ing *ingress.Ingress, status []apiv1.LoadBalancerIngress,
|
|||
}
|
||||
}
|
||||
|
||||
func lessLoadBalancerIngress(addrs []apiv1.LoadBalancerIngress) func(int, int) bool {
|
||||
func lessLoadBalancerIngress(addrs []v1.IngressLoadBalancerIngress) func(int, int) bool {
|
||||
return func(a, b int) bool {
|
||||
switch strings.Compare(addrs[a].Hostname, addrs[b].Hostname) {
|
||||
case -1:
|
||||
|
|
@ -319,7 +320,7 @@ func lessLoadBalancerIngress(addrs []apiv1.LoadBalancerIngress) func(int, int) b
|
|||
}
|
||||
}
|
||||
|
||||
func ingressSliceEqual(lhs, rhs []apiv1.LoadBalancerIngress) bool {
|
||||
func ingressSliceEqual(lhs, rhs []v1.IngressLoadBalancerIngress) bool {
|
||||
if len(lhs) != len(rhs) {
|
||||
return false
|
||||
}
|
||||
|
|
@ -336,7 +337,7 @@ func ingressSliceEqual(lhs, rhs []apiv1.LoadBalancerIngress) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func statusAddressFromService(service string, kubeClient clientset.Interface) ([]apiv1.LoadBalancerIngress, error) {
|
||||
func statusAddressFromService(service string, kubeClient clientset.Interface) ([]v1.IngressLoadBalancerIngress, error) {
|
||||
ns, name, _ := k8s.ParseNameNS(service)
|
||||
svc, err := kubeClient.CoreV1().Services(ns).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
|
@ -345,28 +346,28 @@ func statusAddressFromService(service string, kubeClient clientset.Interface) ([
|
|||
|
||||
switch svc.Spec.Type {
|
||||
case apiv1.ServiceTypeExternalName:
|
||||
return []apiv1.LoadBalancerIngress{{
|
||||
return []v1.IngressLoadBalancerIngress{{
|
||||
Hostname: svc.Spec.ExternalName,
|
||||
}}, nil
|
||||
case apiv1.ServiceTypeClusterIP:
|
||||
return []apiv1.LoadBalancerIngress{{
|
||||
return []v1.IngressLoadBalancerIngress{{
|
||||
IP: svc.Spec.ClusterIP,
|
||||
}}, nil
|
||||
case apiv1.ServiceTypeNodePort:
|
||||
if svc.Spec.ExternalIPs == nil {
|
||||
return []apiv1.LoadBalancerIngress{{
|
||||
return []v1.IngressLoadBalancerIngress{{
|
||||
IP: svc.Spec.ClusterIP,
|
||||
}}, nil
|
||||
}
|
||||
addrs := make([]apiv1.LoadBalancerIngress, len(svc.Spec.ExternalIPs))
|
||||
addrs := make([]v1.IngressLoadBalancerIngress, len(svc.Spec.ExternalIPs))
|
||||
for i, ip := range svc.Spec.ExternalIPs {
|
||||
addrs[i] = apiv1.LoadBalancerIngress{IP: ip}
|
||||
addrs[i] = v1.IngressLoadBalancerIngress{IP: ip}
|
||||
}
|
||||
return addrs, nil
|
||||
case apiv1.ServiceTypeLoadBalancer:
|
||||
addrs := make([]apiv1.LoadBalancerIngress, len(svc.Status.LoadBalancer.Ingress))
|
||||
addrs := make([]v1.IngressLoadBalancerIngress, len(svc.Status.LoadBalancer.Ingress))
|
||||
for i, ingress := range svc.Status.LoadBalancer.Ingress {
|
||||
addrs[i] = apiv1.LoadBalancerIngress{}
|
||||
addrs[i] = v1.IngressLoadBalancerIngress{}
|
||||
if ingress.Hostname != "" {
|
||||
addrs[i].Hostname = ingress.Hostname
|
||||
}
|
||||
|
|
@ -376,7 +377,7 @@ func statusAddressFromService(service string, kubeClient clientset.Interface) ([
|
|||
}
|
||||
for _, ip := range svc.Spec.ExternalIPs {
|
||||
if !stringInIngresses(ip, addrs) {
|
||||
addrs = append(addrs, apiv1.LoadBalancerIngress{IP: ip})
|
||||
addrs = append(addrs, v1.IngressLoadBalancerIngress{IP: ip})
|
||||
}
|
||||
}
|
||||
return addrs, nil
|
||||
|
|
@ -386,7 +387,7 @@ func statusAddressFromService(service string, kubeClient clientset.Interface) ([
|
|||
}
|
||||
|
||||
// stringInSlice returns true if s is in list
|
||||
func stringInIngresses(s string, list []apiv1.LoadBalancerIngress) bool {
|
||||
func stringInIngresses(s string, list []v1.IngressLoadBalancerIngress) bool {
|
||||
for _, v := range list {
|
||||
if v.IP == s || v.Hostname == s {
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ import (
|
|||
"k8s.io/ingress-nginx/pkg/apis/ingress"
|
||||
)
|
||||
|
||||
func buildLoadBalancerIngressByIP() []apiv1.LoadBalancerIngress {
|
||||
return []apiv1.LoadBalancerIngress{
|
||||
func buildLoadBalancerIngressByIP() []networking.IngressLoadBalancerIngress {
|
||||
return []networking.IngressLoadBalancerIngress{
|
||||
{
|
||||
IP: "10.0.0.1",
|
||||
Hostname: "foo1",
|
||||
|
|
@ -123,17 +123,20 @@ func buildSimpleClientSet() *testclient.Clientset {
|
|||
},
|
||||
}},
|
||||
&apiv1.ServiceList{Items: []apiv1.Service{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: apiv1.NamespaceDefault,
|
||||
},
|
||||
Status: apiv1.ServiceStatus{
|
||||
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||
Ingress: buildLoadBalancerIngressByIP(),
|
||||
},
|
||||
},
|
||||
},
|
||||
// This is commented out as the ServiceStatus.LoadBalancer field expects a LoadBalancerStatus object
|
||||
// which is incompatible with the current Ingress struct which expects a IngressLoadBalancerStatus object
|
||||
// TODO: update this service when the ServiceStatus struct gets updated
|
||||
//{
|
||||
// ObjectMeta: metav1.ObjectMeta{
|
||||
// Name: "foo",
|
||||
// Namespace: apiv1.NamespaceDefault,
|
||||
// },
|
||||
// Status: apiv1.ServiceStatus{
|
||||
// LoadBalancer: apiv1.LoadBalancerStatus{
|
||||
// Ingress: buildLoadBalancerIngressByIP(),
|
||||
// },
|
||||
// },
|
||||
//},
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo_non_exist",
|
||||
|
|
@ -199,8 +202,8 @@ func buildExtensionsIngresses() []networking.Ingress {
|
|||
Namespace: apiv1.NamespaceDefault,
|
||||
},
|
||||
Status: networking.IngressStatus{
|
||||
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||
Ingress: []apiv1.LoadBalancerIngress{
|
||||
LoadBalancer: networking.IngressLoadBalancerStatus{
|
||||
Ingress: []networking.IngressLoadBalancerIngress{
|
||||
{
|
||||
IP: "10.0.0.1",
|
||||
Hostname: "foo1",
|
||||
|
|
@ -218,8 +221,8 @@ func buildExtensionsIngresses() []networking.Ingress {
|
|||
},
|
||||
},
|
||||
Status: networking.IngressStatus{
|
||||
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||
Ingress: []apiv1.LoadBalancerIngress{
|
||||
LoadBalancer: networking.IngressLoadBalancerStatus{
|
||||
Ingress: []networking.IngressLoadBalancerIngress{
|
||||
{
|
||||
IP: "0.0.0.0",
|
||||
Hostname: "foo.bar.com",
|
||||
|
|
@ -234,8 +237,8 @@ func buildExtensionsIngresses() []networking.Ingress {
|
|||
Namespace: apiv1.NamespaceDefault,
|
||||
},
|
||||
Status: networking.IngressStatus{
|
||||
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||
Ingress: []apiv1.LoadBalancerIngress{},
|
||||
LoadBalancer: networking.IngressLoadBalancerStatus{
|
||||
Ingress: []networking.IngressLoadBalancerIngress{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -261,7 +264,7 @@ func (til *testIngressLister) ListIngresses() []*ingress.Ingress {
|
|||
Namespace: apiv1.NamespaceDefault,
|
||||
},
|
||||
Status: networking.IngressStatus{
|
||||
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||
LoadBalancer: networking.IngressLoadBalancerStatus{
|
||||
Ingress: buildLoadBalancerIngressByIP(),
|
||||
},
|
||||
},
|
||||
|
|
@ -325,7 +328,7 @@ func TestStatusActions(t *testing.T) {
|
|||
fk.sync("just-test")
|
||||
// PublishService is empty, so the running address is: ["11.0.0.2"]
|
||||
// after updated, the ingress's ip should only be "11.0.0.2"
|
||||
newIPs := []apiv1.LoadBalancerIngress{{
|
||||
newIPs := []networking.IngressLoadBalancerIngress{{
|
||||
IP: "11.0.0.2",
|
||||
}}
|
||||
fooIngress1, err1 := fk.Client.NetworkingV1().Ingresses(apiv1.NamespaceDefault).Get(context.TODO(), "foo_ingress_1", metav1.GetOptions{})
|
||||
|
|
@ -342,7 +345,7 @@ func TestStatusActions(t *testing.T) {
|
|||
// execute shutdown
|
||||
fk.Shutdown()
|
||||
// ingress should be empty
|
||||
newIPs2 := []apiv1.LoadBalancerIngress{}
|
||||
var newIPs2 []networking.IngressLoadBalancerIngress
|
||||
fooIngress2, err2 := fk.Client.NetworkingV1().Ingresses(apiv1.NamespaceDefault).Get(context.TODO(), "foo_ingress_1", metav1.GetOptions{})
|
||||
if err2 != nil {
|
||||
t.Fatalf("unexpected error")
|
||||
|
|
@ -382,7 +385,7 @@ func TestKeyfunc(t *testing.T) {
|
|||
func TestRunningAddressesWithPublishService(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
fakeClient *testclient.Clientset
|
||||
expected []apiv1.LoadBalancerIngress
|
||||
expected []networking.IngressLoadBalancerIngress
|
||||
errExpected bool
|
||||
}{
|
||||
"service type ClusterIP": {
|
||||
|
|
@ -416,7 +419,7 @@ func TestRunningAddressesWithPublishService(t *testing.T) {
|
|||
},
|
||||
},
|
||||
),
|
||||
[]apiv1.LoadBalancerIngress{
|
||||
[]networking.IngressLoadBalancerIngress{
|
||||
{IP: "1.1.1.1"},
|
||||
},
|
||||
false,
|
||||
|
|
@ -437,7 +440,7 @@ func TestRunningAddressesWithPublishService(t *testing.T) {
|
|||
},
|
||||
},
|
||||
),
|
||||
[]apiv1.LoadBalancerIngress{
|
||||
[]networking.IngressLoadBalancerIngress{
|
||||
{IP: "1.1.1.1"},
|
||||
},
|
||||
false,
|
||||
|
|
@ -458,7 +461,7 @@ func TestRunningAddressesWithPublishService(t *testing.T) {
|
|||
},
|
||||
},
|
||||
),
|
||||
[]apiv1.LoadBalancerIngress{
|
||||
[]networking.IngressLoadBalancerIngress{
|
||||
{Hostname: "foo.bar"},
|
||||
},
|
||||
false,
|
||||
|
|
@ -495,7 +498,7 @@ func TestRunningAddressesWithPublishService(t *testing.T) {
|
|||
},
|
||||
},
|
||||
),
|
||||
[]apiv1.LoadBalancerIngress{
|
||||
[]networking.IngressLoadBalancerIngress{
|
||||
{IP: "10.0.0.1"},
|
||||
{Hostname: "foo"},
|
||||
{
|
||||
|
|
@ -530,7 +533,7 @@ func TestRunningAddressesWithPublishService(t *testing.T) {
|
|||
},
|
||||
},
|
||||
),
|
||||
[]apiv1.LoadBalancerIngress{
|
||||
[]networking.IngressLoadBalancerIngress{
|
||||
{IP: "10.0.0.1"},
|
||||
},
|
||||
false,
|
||||
|
|
@ -568,7 +571,7 @@ func TestRunningAddressesWithPublishService(t *testing.T) {
|
|||
}
|
||||
|
||||
if ra == nil {
|
||||
t.Fatalf("returned nil but expected valid []apiv1.LoadBalancerIngress")
|
||||
t.Fatalf("returned nil but expected valid []networking.IngressLoadBalancerIngress")
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(tc.expected, ra) {
|
||||
|
|
@ -584,7 +587,7 @@ func TestRunningAddressesWithPods(t *testing.T) {
|
|||
|
||||
r, _ := fk.runningAddresses()
|
||||
if r == nil {
|
||||
t.Fatalf("returned nil but expected valid []apiv1.LoadBalancerIngress")
|
||||
t.Fatalf("returned nil but expected valid []networking.IngressLoadBalancerIngress")
|
||||
}
|
||||
rl := len(r)
|
||||
if len(r) != 1 {
|
||||
|
|
@ -592,7 +595,7 @@ func TestRunningAddressesWithPods(t *testing.T) {
|
|||
}
|
||||
rv := r[0]
|
||||
if rv.IP != "11.0.0.2" {
|
||||
t.Errorf("returned %v but expected %v", rv, apiv1.LoadBalancerIngress{IP: "11.0.0.2"})
|
||||
t.Errorf("returned %v but expected %v", rv, networking.IngressLoadBalancerIngress{IP: "11.0.0.2"})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -602,7 +605,7 @@ func TestRunningAddressesWithPublishStatusAddress(t *testing.T) {
|
|||
|
||||
ra, _ := fk.runningAddresses()
|
||||
if ra == nil {
|
||||
t.Fatalf("returned nil but expected valid []apiv1.LoadBalancerIngress")
|
||||
t.Fatalf("returned nil but expected valid []networking.IngressLoadBalancerIngress")
|
||||
}
|
||||
rl := len(ra)
|
||||
if len(ra) != 1 {
|
||||
|
|
@ -610,7 +613,7 @@ func TestRunningAddressesWithPublishStatusAddress(t *testing.T) {
|
|||
}
|
||||
rv := ra[0]
|
||||
if rv.IP != "127.0.0.1" {
|
||||
t.Errorf("returned %v but expected %v", rv, apiv1.LoadBalancerIngress{IP: "127.0.0.1"})
|
||||
t.Errorf("returned %v but expected %v", rv, networking.IngressLoadBalancerIngress{IP: "127.0.0.1"})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -620,7 +623,7 @@ func TestRunningAddressesWithPublishStatusAddresses(t *testing.T) {
|
|||
|
||||
ra, _ := fk.runningAddresses()
|
||||
if ra == nil {
|
||||
t.Fatalf("returned nil but expected valid []apiv1.LoadBalancerIngress")
|
||||
t.Fatalf("returned nil but expected valid []networking.IngressLoadBalancerIngress")
|
||||
}
|
||||
rl := len(ra)
|
||||
if len(ra) != 2 {
|
||||
|
|
@ -629,10 +632,10 @@ func TestRunningAddressesWithPublishStatusAddresses(t *testing.T) {
|
|||
rv := ra[0]
|
||||
rv2 := ra[1]
|
||||
if rv.IP != "127.0.0.1" {
|
||||
t.Errorf("returned %v but expected %v", rv, apiv1.LoadBalancerIngress{IP: "127.0.0.1"})
|
||||
t.Errorf("returned %v but expected %v", rv, networking.IngressLoadBalancerIngress{IP: "127.0.0.1"})
|
||||
}
|
||||
if rv2.IP != "1.1.1.1" {
|
||||
t.Errorf("returned %v but expected %v", rv2, apiv1.LoadBalancerIngress{IP: "1.1.1.1"})
|
||||
t.Errorf("returned %v but expected %v", rv2, networking.IngressLoadBalancerIngress{IP: "1.1.1.1"})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -642,7 +645,7 @@ func TestRunningAddressesWithPublishStatusAddressesAndSpaces(t *testing.T) {
|
|||
|
||||
ra, _ := fk.runningAddresses()
|
||||
if ra == nil {
|
||||
t.Fatalf("returned nil but expected valid []apiv1.LoadBalancerIngresst")
|
||||
t.Fatalf("returned nil but expected valid []networking.IngressLoadBalancerIngresst")
|
||||
}
|
||||
rl := len(ra)
|
||||
if len(ra) != 2 {
|
||||
|
|
@ -651,15 +654,15 @@ func TestRunningAddressesWithPublishStatusAddressesAndSpaces(t *testing.T) {
|
|||
rv := ra[0]
|
||||
rv2 := ra[1]
|
||||
if rv.IP != "127.0.0.1" {
|
||||
t.Errorf("returned %v but expected %v", rv, apiv1.LoadBalancerIngress{IP: "127.0.0.1"})
|
||||
t.Errorf("returned %v but expected %v", rv, networking.IngressLoadBalancerIngress{IP: "127.0.0.1"})
|
||||
}
|
||||
if rv2.IP != "1.1.1.1" {
|
||||
t.Errorf("returned %v but expected %v", rv2, apiv1.LoadBalancerIngress{IP: "1.1.1.1"})
|
||||
t.Errorf("returned %v but expected %v", rv2, networking.IngressLoadBalancerIngress{IP: "1.1.1.1"})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStandardizeLoadBalancerIngresses(t *testing.T) {
|
||||
fkEndpoints := []apiv1.LoadBalancerIngress{
|
||||
fkEndpoints := []networking.IngressLoadBalancerIngress{
|
||||
{IP: "2001:db8::68"},
|
||||
{IP: "10.0.0.1"},
|
||||
{Hostname: "opensource-k8s-ingress"},
|
||||
|
|
@ -668,7 +671,7 @@ func TestStandardizeLoadBalancerIngresses(t *testing.T) {
|
|||
r := standardizeLoadBalancerIngresses(fkEndpoints)
|
||||
|
||||
if r == nil {
|
||||
t.Fatalf("returned nil but expected a valid []apiv1.LoadBalancerIngress")
|
||||
t.Fatalf("returned nil but expected a valid []networking.IngressLoadBalancerIngress")
|
||||
}
|
||||
rl := len(r)
|
||||
if rl != 3 {
|
||||
|
|
@ -676,21 +679,21 @@ func TestStandardizeLoadBalancerIngresses(t *testing.T) {
|
|||
}
|
||||
re1 := r[0]
|
||||
if re1.Hostname != "opensource-k8s-ingress" {
|
||||
t.Fatalf("returned %v but expected %v", re1, apiv1.LoadBalancerIngress{Hostname: "opensource-k8s-ingress"})
|
||||
t.Fatalf("returned %v but expected %v", re1, networking.IngressLoadBalancerIngress{Hostname: "opensource-k8s-ingress"})
|
||||
}
|
||||
re2 := r[1]
|
||||
if re2.IP != "10.0.0.1" {
|
||||
t.Fatalf("returned %v but expected %v", re2, apiv1.LoadBalancerIngress{IP: "10.0.0.1"})
|
||||
t.Fatalf("returned %v but expected %v", re2, networking.IngressLoadBalancerIngress{IP: "10.0.0.1"})
|
||||
}
|
||||
re3 := r[2]
|
||||
if re3.IP != "2001:db8::68" {
|
||||
t.Fatalf("returned %v but expected %v", re3, apiv1.LoadBalancerIngress{IP: "2001:db8::68"})
|
||||
t.Fatalf("returned %v but expected %v", re3, networking.IngressLoadBalancerIngress{IP: "2001:db8::68"})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIngressSliceEqual(t *testing.T) {
|
||||
fk1 := buildLoadBalancerIngressByIP()
|
||||
fk2 := append(buildLoadBalancerIngressByIP(), apiv1.LoadBalancerIngress{
|
||||
fk2 := append(buildLoadBalancerIngressByIP(), networking.IngressLoadBalancerIngress{
|
||||
IP: "10.0.0.5",
|
||||
Hostname: "foo5",
|
||||
})
|
||||
|
|
@ -700,8 +703,8 @@ func TestIngressSliceEqual(t *testing.T) {
|
|||
fk4[2].IP = "11.0.0.3"
|
||||
|
||||
fooTests := []struct {
|
||||
lhs []apiv1.LoadBalancerIngress
|
||||
rhs []apiv1.LoadBalancerIngress
|
||||
lhs []networking.IngressLoadBalancerIngress
|
||||
rhs []networking.IngressLoadBalancerIngress
|
||||
er bool
|
||||
}{
|
||||
{fk1, fk1, true},
|
||||
|
|
@ -710,7 +713,7 @@ func TestIngressSliceEqual(t *testing.T) {
|
|||
{fk4, fk1, false},
|
||||
{fk1, nil, false},
|
||||
{nil, nil, true},
|
||||
{[]apiv1.LoadBalancerIngress{}, []apiv1.LoadBalancerIngress{}, true},
|
||||
{[]networking.IngressLoadBalancerIngress{}, []networking.IngressLoadBalancerIngress{}, true},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue