Skip to content

Commit

Permalink
chore: remove support for netv1beta1.Ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Apr 7, 2023
1 parent ff1414d commit 9009a38
Show file tree
Hide file tree
Showing 31 changed files with 624 additions and 1,712 deletions.
22 changes: 2 additions & 20 deletions hack/generators/controllers/networking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import (
const (
outputFile = "../../internal/controllers/configuration/zz_generated_controllers.go"

corev1 = "k8s.io/api/core/v1"
netv1 = "k8s.io/api/networking/v1"
netv1beta1 = "k8s.io/api/networking/v1beta1"
corev1 = "k8s.io/api/core/v1"
netv1 = "k8s.io/api/networking/v1"

kongv1 = "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
kongv1beta1 = "github.com/kong/kubernetes-ingress-controller/v2/api/configuration/v1beta1"
Expand Down Expand Up @@ -89,22 +88,6 @@ var inputControllersNeeded = &typesNeeded{
AcceptsIngressClassNameSpec: false,
RBACVerbs: []string{"get", "list", "watch"},
},
typeNeeded{
Group: "networking.k8s.io",
Version: "v1beta1",
Kind: "Ingress",
PackageImportAlias: "netv1beta1",
PackageAlias: "NetV1Beta1",
Package: netv1beta1,
Plural: "ingresses",
CacheType: "IngressV1beta1",
NeedsStatusPermissions: true,
CapableOfStatusUpdates: true,
AcceptsIngressClassNameAnnotation: true,
AcceptsIngressClassNameSpec: true,
NeedsUpdateReferences: true,
RBACVerbs: []string{"get", "list", "watch"},
},
typeNeeded{
Group: "configuration.konghq.com",
Version: "v1",
Expand Down Expand Up @@ -378,7 +361,6 @@ import (
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
18 changes: 0 additions & 18 deletions internal/controllers/configuration/object_references.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand All @@ -32,8 +31,6 @@ func updateReferredObjects(
referredSecretList = listCoreV1ServiceReferredSecrets(obj)
case *netv1.Ingress:
referredSecretList = listNetV1IngressReferredSecrets(obj)
case *netv1beta1.Ingress:
referredSecretList = listNetV1beta1IngressReferredSecrets(obj)
case *kongv1.KongPlugin:
referredSecretList = listKongPluginReferredSecrets(obj)
case *kongv1.KongClusterPlugin:
Expand Down Expand Up @@ -83,21 +80,6 @@ func listNetV1IngressReferredSecrets(ingress *netv1.Ingress) []types.NamespacedN
return referredSecretNames
}

func listNetV1beta1IngressReferredSecrets(ingress *netv1beta1.Ingress) []types.NamespacedName {
referredSecretNames := make([]types.NamespacedName, 0, len(ingress.Spec.TLS))
for _, tls := range ingress.Spec.TLS {
if tls.SecretName == "" {
continue
}
nsName := types.NamespacedName{
Namespace: ingress.Namespace,
Name: tls.SecretName,
}
referredSecretNames = append(referredSecretNames, nsName)
}
return referredSecretNames
}

func listKongPluginReferredSecrets(plugin *kongv1.KongPlugin) []types.NamespacedName {
referredSecretNames := make([]types.NamespacedName, 0, 1)
if plugin.ConfigFrom != nil {
Expand Down
196 changes: 0 additions & 196 deletions internal/controllers/configuration/zz_generated_controllers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 0 additions & 29 deletions internal/controllers/utils/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
Expand Down Expand Up @@ -36,27 +35,13 @@ func UpdateLoadBalancerIngress(
obj.Status.LoadBalancer.Ingress = netV1ToCoreV1LoadBalancerIngress(newAddresses)
case *kongv1beta1.UDPIngress:
obj.Status.LoadBalancer.Ingress = netV1ToCoreV1LoadBalancerIngress(newAddresses)
case *netv1beta1.Ingress:
obj.Status.LoadBalancer.Ingress = netV1ToV1beta1LoadBalancerIngress(newAddresses)
default:
return false, fmt.Errorf("unsupported ingress type: %T", obj)
}

return true, nil
}

func netV1ToV1beta1LoadBalancerIngress(in []netv1.IngressLoadBalancerIngress) []netv1beta1.IngressLoadBalancerIngress {
out := make([]netv1beta1.IngressLoadBalancerIngress, 0, len(in))
for _, i := range in {
out = append(out, netv1beta1.IngressLoadBalancerIngress{
IP: i.IP,
Hostname: i.Hostname,
// consciously omitting ports as we do not populate them
})
}
return out
}

func netV1ToCoreV1LoadBalancerIngress(in []netv1.IngressLoadBalancerIngress) []corev1.LoadBalancerIngress {
out := make([]corev1.LoadBalancerIngress, 0, len(in))
for _, i := range in {
Expand All @@ -77,25 +62,11 @@ func ingressToNetV1LoadBalancerIngressStatus(in any) ([]netv1.IngressLoadBalance
return coreV1ToNetV1LoadBalancerIngress(obj.Status.LoadBalancer.Ingress), nil
case *kongv1beta1.UDPIngress:
return coreV1ToNetV1LoadBalancerIngress(obj.Status.LoadBalancer.Ingress), nil
case *netv1beta1.Ingress:
return v1beta1ToNetV1LoadBalancerIngress(obj.Status.LoadBalancer.Ingress), nil
default:
return nil, fmt.Errorf("unsupported ingress type: %T", obj)
}
}

func v1beta1ToNetV1LoadBalancerIngress(in []netv1beta1.IngressLoadBalancerIngress) []netv1.IngressLoadBalancerIngress {
out := make([]netv1.IngressLoadBalancerIngress, 0, len(in))
for _, i := range in {
out = append(out, netv1.IngressLoadBalancerIngress{
IP: i.IP,
Hostname: i.Hostname,
// consciously omitting ports as we do not populate them
})
}
return out
}

func coreV1ToNetV1LoadBalancerIngress(in []corev1.LoadBalancerIngress) []netv1.IngressLoadBalancerIngress {
out := make([]netv1.IngressLoadBalancerIngress, 0, len(in))
for _, i := range in {
Expand Down
9 changes: 4 additions & 5 deletions internal/controllers/utils/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
Expand All @@ -34,10 +33,10 @@ func TestUpdateLoadBalancerIngress(t *testing.T) {
},
},
},
&netv1beta1.Ingress{
Status: netv1beta1.IngressStatus{
LoadBalancer: netv1beta1.IngressLoadBalancerStatus{
Ingress: []netv1beta1.IngressLoadBalancerIngress{
&netv1.Ingress{
Status: netv1.IngressStatus{
LoadBalancer: netv1.IngressLoadBalancerStatus{
Ingress: []netv1.IngressLoadBalancerIngress{
{
IP: oldIP,
Hostname: oldHostname,
Expand Down
9 changes: 0 additions & 9 deletions internal/dataplane/parser/ingressrules.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -330,11 +329,3 @@ func servicesAllUseTheSameKongAnnotations(

return match
}

func v1beta1toV1TLS(tlsSections []netv1beta1.IngressTLS) []netv1.IngressTLS {
var v1 []netv1.IngressTLS
for _, item := range tlsSections {
v1 = append(v1, netv1.IngressTLS{Hosts: item.Hosts, SecretName: item.SecretName})
}
return v1
}
Loading

0 comments on commit 9009a38

Please sign in to comment.