Skip to content

Commit 1e5aa24

Browse files
committed
Refactor plus address comments
1 parent 78b0488 commit 1e5aa24

File tree

9 files changed

+257
-165
lines changed

9 files changed

+257
-165
lines changed

api/v1alpha2/linodevpc_types.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ type LinodeVPCSpec struct {
4343
// If set to true, the controller will not delete the VPC resource in Linode.
4444
// Defaults to false.
4545
// +optional
46-
Retain *bool `json:"retain,omitempty"`
46+
// +kubebuilder:default=false
47+
Retain bool `json:"retain,omitempty"`
4748

4849
// CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this VPC. If not
4950
// supplied then the credentials of the controller will be used.
@@ -63,10 +64,10 @@ type VPCSubnetCreateOptions struct {
6364
// +optional
6465
SubnetID int `json:"subnetID,omitempty"`
6566
// Retain allows you to keep the Subnet after the LinodeVPC object is deleted.
66-
// This is only applicable when the parent VPC has RetainVPC set to true and the
67-
// --enable-subnet-deletion flag is enabled on the controller.
67+
// This is only applicable when the parent VPC has RetainVPC set to true.
6868
// +optional
69-
Retain *bool `json:"retain,omitempty"`
69+
// +kubebuilder:default=false
70+
Retain bool `json:"retain,omitempty"`
7071
}
7172

7273
// LinodeVPCStatus defines the observed state of LinodeVPC

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ type flagVars struct {
8888
linodeVPCConcurrency int
8989
linodePlacementGroupConcurrency int
9090
linodeFirewallConcurrency int
91-
enableSubnetDeletion bool
9291
}
9392

9493
func init() {
@@ -153,7 +152,6 @@ func parseFlags() (flags flagVars, opts zap.Options) {
153152
flag.IntVar(&flags.linodeVPCConcurrency, "linodevpc-concurrency", concurrencyDefault, "Number of LinodeVPCs to process simultaneously")
154153
flag.IntVar(&flags.linodePlacementGroupConcurrency, "linodeplacementgroup-concurrency", concurrencyDefault, "Number of Linode Placement Groups to process simultaneously")
155154
flag.IntVar(&flags.linodeFirewallConcurrency, "linodefirewall-concurrency", concurrencyDefault, "Number of Linode Firewall to process simultaneously")
156-
flag.BoolVar(&flags.enableSubnetDeletion, "enable-subnet-deletion", false, "Enable the deletion of subnets in a retained VPC.")
157155

158156
opts = zap.Options{Development: true}
159157
opts.BindFlags(flag.CommandLine)
@@ -295,11 +293,10 @@ func setupControllers(mgr manager.Manager, flags flagVars, linodeClientConfig, d
295293

296294
// LinodeVPC Controller
297295
if err := (&controller.LinodeVPCReconciler{
298-
Client: mgr.GetClient(),
299-
Recorder: mgr.GetEventRecorderFor("LinodeVPCReconciler"),
300-
WatchFilterValue: flags.clusterWatchFilter,
301-
LinodeClientConfig: linodeClientConfig,
302-
EnableSubnetDeletion: flags.enableSubnetDeletion,
296+
Client: mgr.GetClient(),
297+
Recorder: mgr.GetEventRecorderFor("linodevpc-controller"),
298+
LinodeClientConfig: linodeClientConfig,
299+
WatchFilterValue: flags.clusterWatchFilter,
303300
}).SetupWithManager(mgr, crcontroller.Options{MaxConcurrentReconciles: flags.linodeVPCConcurrency}); err != nil {
304301
setupLog.Error(err, "unable to create controller", "controller", "LinodeVPC")
305302
os.Exit(1)

config/crd/bases/infrastructure.cluster.x-k8s.io_linodevpcs.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ spec:
7373
- message: Value is immutable
7474
rule: self == oldSelf
7575
retain:
76+
default: false
7677
description: |-
7778
Retain allows you to keep the VPC after the LinodeVPC object is deleted.
7879
This is useful if you want to use an existing VPC that was not created by this controller.
@@ -90,10 +91,10 @@ spec:
9091
minLength: 3
9192
type: string
9293
retain:
94+
default: false
9395
description: |-
9496
Retain allows you to keep the Subnet after the LinodeVPC object is deleted.
95-
This is only applicable when the parent VPC has RetainVPC set to true and the
96-
--enable-subnet-deletion flag is enabled on the controller.
97+
This is only applicable when the parent VPC has RetainVPC set to true.
9798
type: boolean
9899
subnetID:
99100
description: SubnetID is subnet id for the subnet

docs/src/reference/out.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ _Appears in:_
10591059
| `description` _string_ | | | |
10601060
| `region` _string_ | | | |
10611061
| `subnets` _[VPCSubnetCreateOptions](#vpcsubnetcreateoptions) array_ | | | |
1062-
| `retain` _boolean_ | Retain allows you to keep the VPC after the LinodeVPC object is deleted.<br />This is useful if you want to use an existing VPC that was not created by this controller.<br />If set to true, the controller will not delete the VPC resource in Linode.<br />Defaults to false. | | |
1062+
| `retain` _boolean_ | Retain allows you to keep the VPC after the LinodeVPC object is deleted.<br />This is useful if you want to use an existing VPC that was not created by this controller.<br />If set to true, the controller will not delete the VPC resource in Linode.<br />Defaults to false. | false | |
10631063
| `credentialsRef` _[SecretReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#secretreference-v1-core)_ | CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this VPC. If not<br />supplied then the credentials of the controller will be used. | | |
10641064

10651065

@@ -1218,6 +1218,6 @@ _Appears in:_
12181218
| `label` _string_ | | | MaxLength: 63 <br />MinLength: 3 <br /> |
12191219
| `ipv4` _string_ | | | |
12201220
| `subnetID` _integer_ | SubnetID is subnet id for the subnet | | |
1221-
| `retain` _boolean_ | Retain allows you to keep the Subnet after the LinodeVPC object is deleted.<br />This is only applicable when the parent VPC has RetainVPC set to true and the<br />--enable-subnet-deletion flag is enabled on the controller. | | |
1221+
| `retain` _boolean_ | Retain allows you to keep the Subnet after the LinodeVPC object is deleted.<br />This is only applicable when the parent VPC has RetainVPC set to true. | false | |
12221222

12231223

0 commit comments

Comments
 (0)