update ServiceCIDR API: replace IPv4,IPv6 fields by an array of strings

https: //docs.google.com/document/d/1-CKDPRHsG6XfnGs-Bb7ptWgDtTq9-hj8aJQpGz1CSh8/edit

Change-Id: If7134a5553b4ecc12b1d58ffc52ebb9f8594778a
This commit is contained in:
Antonio Ojea
2023-10-28 20:34:01 +02:00
committed by Antonio Ojea
parent 599597ca65
commit c3d9b77d94
6 changed files with 79 additions and 84 deletions

View File

@@ -2061,6 +2061,17 @@ func TestValidateServiceCIDR(t *testing.T) {
},
},
},
"three-ipranges": {
expectedErrors: 1,
ipRange: &networking.ServiceCIDR{
ObjectMeta: metav1.ObjectMeta{
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
CIDRs: []string{"192.168.0.0/24", "fd00::/64", "10.0.0.0/16"},
},
},
},
"good-iprange-ipv4": {
expectedErrors: 0,
ipRange: &networking.ServiceCIDR{
@@ -2068,7 +2079,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "192.168.0.0/24",
CIDRs: []string{"192.168.0.0/24"},
},
},
},
@@ -2079,7 +2090,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv6: "fd00:1234::/64",
CIDRs: []string{"fd00:1234::/64"},
},
},
},
@@ -2090,8 +2101,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "192.168.0.0/24",
IPv6: "fd00:1234::/64",
CIDRs: []string{"192.168.0.0/24", "fd00:1234::/64"},
},
},
},
@@ -2102,7 +2112,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "sadasdsad",
CIDRs: []string{"asdasdasd"},
},
},
},
@@ -2113,7 +2123,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "192.168.0.1",
CIDRs: []string{"192.168.0.1"},
},
},
},
@@ -2124,7 +2134,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "192.168.0.1/24",
CIDRs: []string{"192.168.0.1/24"},
},
},
},
@@ -2135,7 +2145,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv6: "fd00:1234::2/64",
CIDRs: []string{"fd00:1234::2/64"},
},
},
},
@@ -2146,7 +2156,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv6: "FD00:1234::2/64",
CIDRs: []string{"FD00:1234::2/64"},
},
},
},
@@ -2157,8 +2167,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "192.168.0.0/24",
IPv6: "FD00:1234::/64",
CIDRs: []string{"192.168.0.0/24", "FD00:1234::/64"},
},
},
},
@@ -2169,8 +2178,7 @@ func TestValidateServiceCIDR(t *testing.T) {
Name: "test-name",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "192.168.007.0/24",
IPv6: "fd00:1234::/64",
CIDRs: []string{"192.168.007.0/24", "fd00:1234::/64"},
},
},
},
@@ -2193,8 +2201,7 @@ func TestValidateServiceCIDRUpdate(t *testing.T) {
ResourceVersion: "1",
},
Spec: networking.ServiceCIDRSpec{
IPv4: "192.168.0.0/24",
IPv6: "2001:db2::/64",
CIDRs: []string{"192.168.0.0/24", "fd00:1234::/64"},
},
}
@@ -2213,27 +2220,18 @@ func TestValidateServiceCIDRUpdate(t *testing.T) {
},
{
name: "Failed update, update spec.IPv4",
name: "Failed update, update spec.CIDRs single stack",
svc: func(svc *networking.ServiceCIDR) *networking.ServiceCIDR {
out := svc.DeepCopy()
out.Spec.IPv4 = "10.0.0.0/16"
out.Spec.CIDRs = []string{"10.0.0.0/16"}
return out
}, expectErr: true,
},
{
name: "Failed update, update spec.IPv6",
name: "Failed update, update spec.CIDRs dual stack",
svc: func(svc *networking.ServiceCIDR) *networking.ServiceCIDR {
out := svc.DeepCopy()
out.Spec.IPv6 = "fd00:1:2:3::/64"
return out
}, expectErr: true,
},
{
name: "Failed update, update spec.IPv4 and spec.IPv6",
svc: func(svc *networking.ServiceCIDR) *networking.ServiceCIDR {
out := svc.DeepCopy()
out.Spec.IPv4 = "10.0.0.0/16"
out.Spec.IPv6 = "fd00:1:2:3::/64"
out.Spec.CIDRs = []string{"10.0.0.0/24", "fd00:1234::/64"}
return out
}, expectErr: true,
},