Skip to content

Commit 22e80dc

Browse files
authored
Refactor VPCSpec.CIDRBlock into CIDRBlocks (#84)
Issue #, if available: aws-controllers-k8s/community#1198 Description of changes: VPCs can have multiple IPv4 CIDR blocks associated with it; therefore, refactor VPC's Spec `CIDRBlock` field into `CIDRBlocks` to support a list of CIDR blocks. The **first** entry in `VPCSpec.CIDRBlocks` will be used as the **primary** IPv4 CIDR block upon VPC creation. This is prerequisite work for `Update` logic and supporting multiple CIDR blocks will be enabled in a subsequent PR. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 484c27c commit 22e80dc

File tree

13 files changed

+144
-145
lines changed

13 files changed

+144
-145
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-08-22T17:29:13Z"
2+
build_date: "2022-08-30T21:16:34Z"
33
build_hash: 87477ae8ca8ac6ddb8c565bbd910cc7e30f55ed0
44
go_version: go1.18.1
55
version: v0.19.3
6-
api_directory_checksum: ff86d89efc3212fed4eb14bdc83af54601428a83
6+
api_directory_checksum: 5ce1a3bbdc20416fec04fb2551900c42d8b2034e
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.42.0
99
generator_config_info:
10-
file_checksum: 941aba834f0ab63e4555013717c7d9d96747ed9c
10+
file_checksum: 1e5e8980ffcaabb7164424dd6eda12d5e693f55b
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ignore:
2222
- CreateSubnetInput.TagSpecifications
2323
- CreateTransitGatewayInput.DryRun
2424
- CreateTransitGatewayInput.TagSpecifications
25+
- CreateVpcInput.CidrBlock
26+
- CreateVpcOutput.Vpc.CidrBlock
2527
- CreateVpcInput.DryRun
2628
- CreateVpcInput.TagSpecifications
2729
- CreateVpcEndpointInput.DryRun
@@ -423,6 +425,9 @@ resources:
423425
terminal_codes:
424426
- InvalidParameterValue
425427
fields:
428+
CIDRBlocks:
429+
custom_field:
430+
list_of: String
426431
EnableDNSSupport:
427432
from:
428433
operation: ModifyVpcAttribute

apis/v1alpha1/types.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/vpc.go

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/ec2.services.k8s.aws_vpcs.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ spec:
4242
prefix length for the VPC. You cannot specify the range of IP addresses,
4343
or the size of the CIDR block.
4444
type: boolean
45-
cidrBlock:
46-
description: The IPv4 network range for the VPC, in CIDR notation.
47-
For example, 10.0.0.0/16. We modify the specified CIDR block to
48-
its canonical form; for example, if you specify 100.68.0.18/18,
49-
we modify it to 100.68.0.0/18.
50-
type: string
45+
cidrBlocks:
46+
items:
47+
type: string
48+
type: array
5149
enableDNSHostnames:
5250
description: The attribute value. The valid values are true or false.
5351
type: boolean
@@ -92,8 +90,6 @@ spec:
9290
type: string
9391
type: object
9492
type: array
95-
required:
96-
- cidrBlock
9793
type: object
9894
status:
9995
description: VPCStatus defines the observed state of VPC

generator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ignore:
2222
- CreateSubnetInput.TagSpecifications
2323
- CreateTransitGatewayInput.DryRun
2424
- CreateTransitGatewayInput.TagSpecifications
25+
- CreateVpcInput.CidrBlock
26+
- CreateVpcOutput.Vpc.CidrBlock
2527
- CreateVpcInput.DryRun
2628
- CreateVpcInput.TagSpecifications
2729
- CreateVpcEndpointInput.DryRun
@@ -423,6 +425,9 @@ resources:
423425
terminal_codes:
424426
- InvalidParameterValue
425427
fields:
428+
CIDRBlocks:
429+
custom_field:
430+
list_of: String
426431
EnableDNSSupport:
427432
from:
428433
operation: ModifyVpcAttribute

helm/crds/ec2.services.k8s.aws_vpcs.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ spec:
4242
prefix length for the VPC. You cannot specify the range of IP addresses,
4343
or the size of the CIDR block.
4444
type: boolean
45-
cidrBlock:
46-
description: The IPv4 network range for the VPC, in CIDR notation.
47-
For example, 10.0.0.0/16. We modify the specified CIDR block to
48-
its canonical form; for example, if you specify 100.68.0.18/18,
49-
we modify it to 100.68.0.0/18.
50-
type: string
45+
cidrBlocks:
46+
items:
47+
type: string
48+
type: array
5149
enableDNSHostnames:
5250
description: The attribute value. The valid values are true or false.
5351
type: boolean
@@ -92,8 +90,6 @@ spec:
9290
type: string
9391
type: object
9492
type: array
95-
required:
96-
- cidrBlock
9793
type: object
9894
status:
9995
description: VPCStatus defines the observed state of VPC

pkg/resource/vpc/delta.go

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/vpc/hook.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ func (rm *resourceManager) customUpdate(
177177
return &resource{ko}, nil
178178
}
179179

180+
// applyPrimaryCIDRBlockInCreateRequest populates
181+
// CreateVpcInput.CidrBlock field with the FIRST
182+
// CIDR block defined in the resource's Spec
183+
func applyPrimaryCIDRBlockInCreateRequest(r *resource,
184+
input *svcsdk.CreateVpcInput) {
185+
if r.ko.Spec.CIDRBlocks != nil && len(r.ko.Spec.CIDRBlocks) > 0 {
186+
input.CidrBlock = r.ko.Spec.CIDRBlocks[0]
187+
}
188+
}
189+
180190
// updateTagSpecificationsInCreateRequest adds
181191
// Tags defined in the Spec to CreateVpcInput.TagSpecification
182192
// and ensures the ResourceType is always set to 'vpc'

0 commit comments

Comments
 (0)