Skip to content

Commit 130b37f

Browse files
committed
added skip vcn and subnet functionality without nsg skip
1 parent 359bc8f commit 130b37f

8 files changed

+422
-0
lines changed

api/v1beta2/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,9 @@ type Subnet struct {
854854
ID *string `json:"id,omitempty"`
855855
// Subnet Name.
856856
Name string `json:"name"`
857+
// Skip specifies whether to skip creating subnets.
858+
// +optional
859+
Skip bool `json:"skip,omitempty"`
857860
// Subnet CIDR.
858861
// +optional
859862
CIDR string `json:"cidr,omitempty"`
@@ -906,6 +909,10 @@ type VCN struct {
906909
// +optional
907910
Name string `json:"name"`
908911

912+
// Skip specifies whether to skip creating VCN.
913+
// +optional
914+
Skip bool `json:"skip,omitempty"`
915+
909916
// VCN CIDR.
910917
// +optional
911918
// Deprecated, please use NetworkDetails.cidrs

cloud/scope/subnet_reconciler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import (
3232
func (s *ClusterScope) ReconcileSubnet(ctx context.Context) error {
3333
desiredSubnets := s.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets
3434
for _, desiredSubnet := range desiredSubnets {
35+
if desiredSubnet.Skip {
36+
continue
37+
}
3538
subnet, err := s.GetSubnet(ctx, *desiredSubnet)
3639
if err != nil {
3740
return err
@@ -188,6 +191,9 @@ func (s *ClusterScope) UpdateSubnet(ctx context.Context, spec infrastructurev1be
188191
func (s *ClusterScope) DeleteSubnets(ctx context.Context) error {
189192
desiredSubnets := s.GetSubnetsSpec()
190193
for _, desiredSubnet := range desiredSubnets {
194+
if desiredSubnet.Skip {
195+
continue
196+
}
191197
subnet, err := s.GetSubnet(ctx, *desiredSubnet)
192198
if err != nil && !ociutil.IsNotFound(err) {
193199
return err

cloud/scope/vcn_reconciler.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import (
2828
)
2929

3030
func (s *ClusterScope) ReconcileVCN(ctx context.Context) error {
31+
if s.OCIClusterAccessor.GetNetworkSpec().Vcn.Skip {
32+
s.Logger.Info("Skipping VCN reconciliation as per spec")
33+
return nil
34+
}
3135
spec := s.OCIClusterAccessor.GetNetworkSpec().Vcn
3236

3337
var err error
@@ -150,6 +154,10 @@ func (s *ClusterScope) CreateVCN(ctx context.Context, spec infrastructurev1beta2
150154
}
151155

152156
func (s *ClusterScope) DeleteVCN(ctx context.Context) error {
157+
if s.OCIClusterAccessor.GetNetworkSpec().Vcn.Skip {
158+
s.Logger.Info("Skipping VCN reconciliation as per spec")
159+
return nil
160+
}
153161
vcn, err := s.GetVCN(ctx)
154162

155163
if err != nil && !ociutil.IsNotFound(err) {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ spec:
186186
id:
187187
description: VCN OCID.
188188
type: string
189+
skip:
190+
description: Skip specifies whether to skip creating vcn
191+
type: boolean
189192
internetGatewayId:
190193
description: ID of Internet Gateway.
191194
type: string
@@ -600,6 +603,9 @@ spec:
600603
id:
601604
description: Subnet OCID.
602605
type: string
606+
skip:
607+
description: Skip specifies whether to skip creating subnet
608+
type: boolean
603609
name:
604610
description: Subnet Name.
605611
type: string
@@ -1408,6 +1414,9 @@ spec:
14081414
id:
14091415
description: VCN OCID.
14101416
type: string
1417+
skip:
1418+
description: Skip specifies whether to skip creating vcn
1419+
type: boolean
14111420
internetGateway:
14121421
description: Configuration for Internet Gateway.
14131422
properties:
@@ -1881,6 +1890,9 @@ spec:
18811890
id:
18821891
description: Subnet OCID.
18831892
type: string
1893+
skip:
1894+
description: Skip specifies whether to skip creating subnet
1895+
type: boolean
18841896
name:
18851897
description: Subnet Name.
18861898
type: string

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ spec:
201201
id:
202202
description: VCN OCID.
203203
type: string
204+
skip:
205+
description: Skip specifies whether to skip creating vcn
206+
type: boolean
204207
internetGatewayId:
205208
description: ID of Internet Gateway.
206209
type: string
@@ -667,6 +670,9 @@ spec:
667670
id:
668671
description: Subnet OCID.
669672
type: string
673+
skip:
674+
description: Skip specifies whether to skip creating subnet
675+
type: boolean
670676
name:
671677
description: Subnet Name.
672678
type: string
@@ -1468,6 +1474,9 @@ spec:
14681474
id:
14691475
description: VCN OCID.
14701476
type: string
1477+
skip:
1478+
description: Skip specifies whether to skip creating vcn
1479+
type: boolean
14711480
internetGateway:
14721481
description: Configuration for Internet Gateway.
14731482
properties:
@@ -1999,6 +2008,9 @@ spec:
19992008
id:
20002009
description: Subnet OCID.
20012010
type: string
2011+
skip:
2012+
description: Skip specifies whether to skip creating subnet
2013+
type: boolean
20022014
name:
20032015
description: Subnet Name.
20042016
type: string

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ spec:
186186
id:
187187
description: VCN OCID.
188188
type: string
189+
skip:
190+
description: Skip specifies whether to skip creating vcn
191+
type: boolean
189192
internetGatewayId:
190193
description: ID of Internet Gateway.
191194
type: string
@@ -597,6 +600,9 @@ spec:
597600
id:
598601
description: Subnet OCID.
599602
type: string
603+
skip:
604+
description: Skip specifies whether to skip creating subnet
605+
type: boolean
600606
name:
601607
description: Subnet Name.
602608
type: string
@@ -1405,6 +1411,9 @@ spec:
14051411
id:
14061412
description: VCN OCID.
14071413
type: string
1414+
skip:
1415+
description: Skip specifies whether to skip creating vcn
1416+
type: boolean
14081417
internetGateway:
14091418
description: Configuration for Internet Gateway.
14101419
properties:
@@ -1875,6 +1884,9 @@ spec:
18751884
id:
18761885
description: Subnet OCID.
18771886
type: string
1887+
skip:
1888+
description: Skip specifies whether to skip creating subnet
1889+
type: boolean
18781890
name:
18791891
description: Subnet Name.
18801892
type: string

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ spec:
206206
id:
207207
description: VCN OCID.
208208
type: string
209+
skip:
210+
description: Skip specifies whether to skip creating vcn
211+
type: boolean
209212
internetGatewayId:
210213
description: ID of Internet Gateway.
211214
type: string
@@ -672,6 +675,9 @@ spec:
672675
id:
673676
description: Subnet OCID.
674677
type: string
678+
skip:
679+
description: Skip specifies whether to skip creating subnet
680+
type: boolean
675681
name:
676682
description: Subnet Name.
677683
type: string
@@ -1478,6 +1484,9 @@ spec:
14781484
id:
14791485
description: VCN OCID.
14801486
type: string
1487+
skip:
1488+
description: Skip specifies whether to skip creating vcn
1489+
type: boolean
14811490
internetGateway:
14821491
description: Configuration for Internet Gateway.
14831492
properties:
@@ -2009,6 +2018,9 @@ spec:
20092018
id:
20102019
description: Subnet OCID.
20112020
type: string
2021+
skip:
2022+
description: Skip specifies whether to skip creating subnet
2023+
type: boolean
20122024
name:
20132025
description: Subnet Name.
20142026
type: string

0 commit comments

Comments
 (0)