From c38353a0f103968aff5ff12d8905c342328f4891 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Wed, 21 Dec 2022 10:10:09 -0800 Subject: [PATCH] Update Ingress status --- internal/k8s/status.go | 14 +++++++------- internal/k8s/status_test.go | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/k8s/status.go b/internal/k8s/status.go index 78b9a67235..bec7dcf5a7 100644 --- a/internal/k8s/status.go +++ b/internal/k8s/status.go @@ -35,7 +35,7 @@ type statusUpdater struct { bigIPAddress string bigIPPorts string externalEndpoints []conf_v1.ExternalEndpoint - status []api_v1.LoadBalancerIngress + status []networking.IngressLoadBalancerIngress statusInitialized bool keyFunc func(obj interface{}) (string, error) namespacedInformers map[string]*namespacedInformer @@ -96,7 +96,7 @@ func (su *statusUpdater) UpdateExternalEndpointsForResource(r Resource) error { // ClearIngressStatus clears the Ingress status. func (su *statusUpdater) ClearIngressStatus(ing networking.Ingress) error { - return su.updateIngressWithStatus(ing, []api_v1.LoadBalancerIngress{}) + return su.updateIngressWithStatus(ing, []networking.IngressLoadBalancerIngress{}) } // UpdateIngressStatus updates the status on the selected Ingress. @@ -126,7 +126,7 @@ func (su *statusUpdater) getNamespacedInformer(ns string) *namespacedInformer { } // updateIngressWithStatus sets the provided status on the selected Ingress. -func (su *statusUpdater) updateIngressWithStatus(ing networking.Ingress, status []api_v1.LoadBalancerIngress) error { +func (su *statusUpdater) updateIngressWithStatus(ing networking.Ingress, status []networking.IngressLoadBalancerIngress) error { // Get an up-to-date Ingress from the Store key, err := su.keyFunc(&ing) if err != nil { @@ -212,12 +212,12 @@ func (su *statusUpdater) retryStatusUpdate(clientIngress typednetworking.Ingress // saveStatus saves the string array of IPs or addresses that we will set as status // on all the Ingresses that we manage. func (su *statusUpdater) saveStatus(ips []string) { - statusIngs := []api_v1.LoadBalancerIngress{} + statusIngs := []networking.IngressLoadBalancerIngress{} for _, ip := range ips { if net.ParseIP(ip) == nil { - statusIngs = append(statusIngs, api_v1.LoadBalancerIngress{Hostname: ip}) + statusIngs = append(statusIngs, networking.IngressLoadBalancerIngress{Hostname: ip}) } else { - statusIngs = append(statusIngs, api_v1.LoadBalancerIngress{IP: ip}) + statusIngs = append(statusIngs, networking.IngressLoadBalancerIngress{IP: ip}) } } su.status = statusIngs @@ -664,7 +664,7 @@ func (su *statusUpdater) updateVirtualServerRouteExternalEndpoints(vsr *conf_v1. return err } -func (su *statusUpdater) generateExternalEndpointsFromStatus(status []api_v1.LoadBalancerIngress) []conf_v1.ExternalEndpoint { +func (su *statusUpdater) generateExternalEndpointsFromStatus(status []networking.IngressLoadBalancerIngress) []conf_v1.ExternalEndpoint { var externalEndpoints []conf_v1.ExternalEndpoint for _, lb := range status { ports := su.externalServicePorts diff --git a/internal/k8s/status_test.go b/internal/k8s/status_test.go index 43572f680d..9dd1c10cf2 100644 --- a/internal/k8s/status_test.go +++ b/internal/k8s/status_test.go @@ -193,8 +193,8 @@ func TestStatusUpdateWithExternalStatusAndExternalService(t *testing.T) { Namespace: "namespace", }, Status: networking.IngressStatus{ - LoadBalancer: v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{ + LoadBalancer: networking.IngressLoadBalancerStatus{ + Ingress: []networking.IngressLoadBalancerIngress{ { IP: "1.2.3.4", }, @@ -299,8 +299,8 @@ func TestStatusUpdateWithExternalStatusAndIngressLink(t *testing.T) { Namespace: "namespace", }, Status: networking.IngressStatus{ - LoadBalancer: v1.LoadBalancerStatus{ - Ingress: []v1.LoadBalancerIngress{ + LoadBalancer: networking.IngressLoadBalancerStatus{ + Ingress: []networking.IngressLoadBalancerIngress{ { IP: "1.2.3.4", }, @@ -409,7 +409,7 @@ func TestGenerateExternalEndpointsFromStatus(t *testing.T) { }{ { su: statusUpdater{ - status: []v1.LoadBalancerIngress{ + status: []networking.IngressLoadBalancerIngress{ { IP: "8.8.8.8", }, @@ -421,7 +421,7 @@ func TestGenerateExternalEndpointsFromStatus(t *testing.T) { }, { su: statusUpdater{ - status: []v1.LoadBalancerIngress{ + status: []networking.IngressLoadBalancerIngress{ { Hostname: "my-loadbalancer.example.com", },