Change Ingress version from v1beta1 to v1 for K8s 1.22+ compatibility (#2124)

* Change Ingress version from v1beta1 to v1 for K8s 1.22+ compatibility

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Minor fix

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2021-07-26 09:50:42 +05:30
committed by GitHub
parent eb72fdc717
commit 8bd1a71065
3 changed files with 121 additions and 113 deletions
+99 -92
View File
@@ -20,9 +20,8 @@ import (
"reflect"
"testing"
"k8s.io/api/extensions/v1beta1"
v1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
fv1 "github.com/fission/fission/pkg/apis/core/v1"
)
@@ -35,7 +34,7 @@ func TestGetIngressSpec(t *testing.T) {
tests := []struct {
name string
args args
want *v1beta1.Ingress
want *v1.Ingress
}{
{
name: "host-backward-compatibility",
@@ -58,7 +57,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -69,19 +68,20 @@ func TestGetIngressSpec(t *testing.T) {
Namespace: "foobarNS",
Annotations: nil,
},
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
Spec: v1.IngressSpec{
Rules: []v1.IngressRule{
{
Host: "test.com",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/bar",
@@ -116,7 +116,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -129,19 +129,20 @@ func TestGetIngressSpec(t *testing.T) {
"key": "value",
},
},
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
Spec: v1.IngressSpec{
Rules: []v1.IngressRule{
{
Host: "",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/bar",
@@ -176,7 +177,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -187,19 +188,20 @@ func TestGetIngressSpec(t *testing.T) {
Namespace: "foobarNS",
Annotations: nil,
},
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
Spec: v1.IngressSpec{
Rules: []v1.IngressRule{
{
Host: "test.com",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/bar",
@@ -234,7 +236,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -245,19 +247,20 @@ func TestGetIngressSpec(t *testing.T) {
Namespace: "foobarNS",
Annotations: nil,
},
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
Spec: v1.IngressSpec{
Rules: []v1.IngressRule{
{
Host: "",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/{bar}",
@@ -292,7 +295,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -303,19 +306,20 @@ func TestGetIngressSpec(t *testing.T) {
Namespace: "foobarNS",
Annotations: nil,
},
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
Spec: v1.IngressSpec{
Rules: []v1.IngressRule{
{
Host: "",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/{bar}",
@@ -351,7 +355,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -362,19 +366,20 @@ func TestGetIngressSpec(t *testing.T) {
Namespace: "foobarNS",
Annotations: nil,
},
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
Spec: v1.IngressSpec{
Rules: []v1.IngressRule{
{
Host: "test.com",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/bar",
@@ -409,7 +414,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -420,19 +425,20 @@ func TestGetIngressSpec(t *testing.T) {
Namespace: "foobarNS",
Annotations: nil,
},
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
Spec: v1.IngressSpec{
Rules: []v1.IngressRule{
{
Host: "",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/bar",
@@ -469,7 +475,7 @@ func TestGetIngressSpec(t *testing.T) {
},
},
},
want: &v1beta1.Ingress{
want: &v1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"triggerName": "foo",
@@ -482,8 +488,8 @@ func TestGetIngressSpec(t *testing.T) {
"key": "value",
},
},
Spec: v1beta1.IngressSpec{
TLS: []v1beta1.IngressTLS{
Spec: v1.IngressSpec{
TLS: []v1.IngressTLS{
{
Hosts: []string{
"test.com",
@@ -491,18 +497,19 @@ func TestGetIngressSpec(t *testing.T) {
SecretName: "foobar",
},
},
Rules: []v1beta1.IngressRule{
Rules: []v1.IngressRule{
{
Host: "",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
IngressRuleValue: v1.IngressRuleValue{
HTTP: &v1.HTTPIngressRuleValue{
Paths: []v1.HTTPIngressPath{
{
Backend: v1beta1.IngressBackend{
ServiceName: "router",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 80,
Backend: v1.IngressBackend{
Service: &v1.IngressServiceBackend{
Name: "router",
Port: v1.ServiceBackendPort{
Number: 80,
},
},
},
Path: "/foo/bar",