Skip to content

Commit

Permalink
Added validation and comment for all ipv6 related fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed Sep 2, 2022
1 parent 6455529 commit b358bd9
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 144 deletions.
6 changes: 3 additions & 3 deletions api/v1alpha3/zz_generated.conversion.go

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

9 changes: 3 additions & 6 deletions api/v1alpha4/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions api/v1beta1/awscluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,10 @@ func (r *AWSCluster) validateNetwork() field.ErrorList {
if r.Spec.NetworkSpec.VPC.IsIPv6Enabled() {
allErrs = append(allErrs, field.Invalid(field.NewPath("ipv6"), r.Spec.NetworkSpec.VPC.IPv6, "IPv6 cannot be used with unmanaged clusters at this time."))
}
for _, subnet := range r.Spec.NetworkSpec.Subnets {
if subnet.IsIPv6 || subnet.IPv6CidrBlock != "" {
allErrs = append(allErrs, field.Invalid(field.NewPath("subnets"), r.Spec.NetworkSpec.Subnets, "IPv6 cannot be used with unmanaged clusters at this time."))
}
}
return allErrs
}
35 changes: 35 additions & 0 deletions api/v1beta1/awscluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,41 @@ func TestAWSCluster_ValidateCreate(t *testing.T) {
},
wantErr: true,
},
{
name: "rejects ipv6 enabled subnet",
cluster: &AWSCluster{
Spec: AWSClusterSpec{
NetworkSpec: NetworkSpec{
Subnets: []SubnetSpec{
{
ID: "sub-1",
IsIPv6: true,
},
{
ID: "sub-2",
},
},
},
},
},
wantErr: true,
},
{
name: "rejects ipv6 cidr block for subnets",
cluster: &AWSCluster{
Spec: AWSClusterSpec{
NetworkSpec: NetworkSpec{
Subnets: []SubnetSpec{
{
ID: "sub-1",
IPv6CidrBlock: "2022:1234:5678:9101::/64",
},
},
},
},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
6 changes: 5 additions & 1 deletion api/v1beta1/network_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ type VPCSpec struct {
// Defaults to 10.0.0.0/16.
CidrBlock string `json:"cidrBlock,omitempty"`

// IPv6 contains ipv6 specific settings for the network.
// IPv6 contains ipv6 specific settings for the network. Supported only in managed clusters.
// This field cannot be set on AWSCluster object.
// +optional
IPv6 *IPv6 `json:"ipv6,omitempty"`

Expand Down Expand Up @@ -248,6 +249,8 @@ type SubnetSpec struct {

// IPv6CidrBlock is the IPv6 CIDR block to be used when the provider creates a managed VPC.
// A subnet can have an IPv4 and an IPv6 address.
// IPv6 is only supported in managed clusters, this field cannot be set on AWSCluster object.
// +optional
IPv6CidrBlock string `json:"ipv6CidrBlock,omitempty"`

// AvailabilityZone defines the availability zone to use for this subnet in the cluster's region.
Expand All @@ -258,6 +261,7 @@ type SubnetSpec struct {
IsPublic bool `json:"isPublic"`

// IsIPv6 defines the subnet as an IPv6 subnet. A subnet is IPv6 when it is associated with a VPC that has IPv6 enabled.
// IPv6 is only supported in managed clusters, this field cannot be set on AWSCluster object.
// +optional
IsIPv6 bool `json:"isIpv6,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2529,12 +2529,15 @@ spec:
ipv6CidrBlock:
description: IPv6CidrBlock is the IPv6 CIDR block to be
used when the provider creates a managed VPC. A subnet
can have an IPv4 and an IPv6 address.
can have an IPv4 and an IPv6 address. IPv6 is only supported
in managed clusters, this field cannot be set on AWSCluster
object.
type: string
isIpv6:
description: IsIPv6 defines the subnet as an IPv6 subnet.
A subnet is IPv6 when it is associated with a VPC that
has IPv6 enabled.
has IPv6 enabled. IPv6 is only supported in managed clusters,
this field cannot be set on AWSCluster object.
type: boolean
isPublic:
description: IsPublic defines the subnet as a public subnet.
Expand Down Expand Up @@ -2599,7 +2602,8 @@ spec:
type: string
ipv6:
description: IPv6 contains ipv6 specific settings for the
network.
network. Supported only in managed clusters. This field
cannot be set on AWSCluster object.
properties:
cidrBlock:
description: CidrBlock is the CIDR block provided by Amazon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1787,12 +1787,15 @@ spec:
ipv6CidrBlock:
description: IPv6CidrBlock is the IPv6 CIDR block to be
used when the provider creates a managed VPC. A subnet
can have an IPv4 and an IPv6 address.
can have an IPv4 and an IPv6 address. IPv6 is only supported
in managed clusters, this field cannot be set on AWSCluster
object.
type: string
isIpv6:
description: IsIPv6 defines the subnet as an IPv6 subnet.
A subnet is IPv6 when it is associated with a VPC that
has IPv6 enabled.
has IPv6 enabled. IPv6 is only supported in managed clusters,
this field cannot be set on AWSCluster object.
type: boolean
isPublic:
description: IsPublic defines the subnet as a public subnet.
Expand Down Expand Up @@ -1857,7 +1860,8 @@ spec:
type: string
ipv6:
description: IPv6 contains ipv6 specific settings for the
network.
network. Supported only in managed clusters. This field
cannot be set on AWSCluster object.
properties:
cidrBlock:
description: CidrBlock is the CIDR block provided by Amazon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,15 @@ spec:
description: IPv6CidrBlock is the IPv6 CIDR block
to be used when the provider creates a managed
VPC. A subnet can have an IPv4 and an IPv6 address.
IPv6 is only supported in managed clusters, this
field cannot be set on AWSCluster object.
type: string
isIpv6:
description: IsIPv6 defines the subnet as an IPv6
subnet. A subnet is IPv6 when it is associated
with a VPC that has IPv6 enabled.
with a VPC that has IPv6 enabled. IPv6 is only
supported in managed clusters, this field cannot
be set on AWSCluster object.
type: boolean
isPublic:
description: IsPublic defines the subnet as a public
Expand Down Expand Up @@ -691,7 +695,8 @@ spec:
type: string
ipv6:
description: IPv6 contains ipv6 specific settings
for the network.
for the network. Supported only in managed clusters.
This field cannot be set on AWSCluster object.
properties:
cidrBlock:
description: CidrBlock is the CIDR block provided
Expand Down
126 changes: 0 additions & 126 deletions templates/cluster-template-ipv6.yaml

This file was deleted.

0 comments on commit b358bd9

Please sign in to comment.