Skip to content

Commit 32b00c9

Browse files
committed
adding comments and changes for more clarity
1 parent 8c21afd commit 32b00c9

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

api/v1beta1/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ type Subnet struct {
856856
Name string `json:"name"`
857857
// Skip specifies whether to skip creating subnets.
858858
// +optional
859-
860859
Skip bool `json:"skip,omitempty"`
861860
// Subnet CIDR.
862861
// +optional
@@ -911,6 +910,7 @@ type VCN struct {
911910
Name string `json:"name"`
912911

913912
// Skip specifies whether to skip creating VCN.
913+
// When is set to true, InternetGateway, NatGateway, ServiceGateway, RouteTable should be also have Skip set to true
914914
// +optional
915915
Skip bool `json:"skip,omitempty"`
916916

api/v1beta2/ocicluster_webhook.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (c *OCICluster) ValidateCreate() (admission.Warnings, error) {
9494
}
9595
}
9696

97-
// If Skip field is True, ID field of VCN should be specified
97+
// If Skip field is true, ID field of VCN should be specified
9898
if c.Spec.NetworkSpec.Vcn.Skip == *common.Bool(true) {
9999
if c.Spec.NetworkSpec.Vcn.ID == common.String("") || c.Spec.NetworkSpec.Vcn.ID == nil {
100100
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "NetworkSpec.Vcn.ID"), c.Spec.NetworkSpec.Vcn.ID, "field is required"))
@@ -120,22 +120,24 @@ func (c *OCICluster) ValidateCreate() (admission.Warnings, error) {
120120
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "NetworkSpec.Vcn.RouteTable.Skip"), c.Spec.NetworkSpec.Vcn.RouteTable.Skip, "field requires to be true when VCN is skipped"))
121121
}
122122

123-
// For each subnet if Skip field is True, ID field of Subnet should be specified
124-
// Also for each subnet if ID field is True, Skip field of Subnet should be true
123+
// For each subnet
125124
for _, subnet := range c.Spec.NetworkSpec.Vcn.Subnets {
125+
126+
// if Skip field is true, ID field of Subnet should also be specified
126127
if subnet.Skip == *common.Bool(true) {
127128
if subnet.ID == common.String("") || subnet.ID == nil {
128129
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "subnet.ID"), subnet.ID, "field is required"))
129130
}
130131
}
132+
// if ID field is specified, Skip field of Subnet should also be true
131133
if subnet.ID != common.String("") {
132134
if subnet.Skip != *common.Bool(true) {
133135
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "subnet.Skip"), subnet.Skip, "field requires to be true if Subnet ID is specified"))
134136
}
135137
}
136138
}
137139
} else {
138-
// If Skip field is False, for each subnet in VCN the Skip field of Subnet cannot be true
140+
// If Skip field of VCN is false, for each subnet in that VCN the Skip field of Subnet cannot be true
139141
for _, subnet := range c.Spec.NetworkSpec.Vcn.Subnets {
140142
if subnet.Skip == *common.Bool(true) {
141143
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "subnet.Skip"), subnet.Skip, "field cannot be true when VCN is not skipped"))
@@ -182,7 +184,7 @@ func (c *OCICluster) ValidateUpdate(old runtime.Object) (admission.Warnings, err
182184
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "compartmentId"), c.Spec.CompartmentId, "field is immutable"))
183185
}
184186

185-
// If Skip field is True, ID field of VCN should be specified
187+
// If Skip field is true, ID field of VCN should be specified
186188
if c.Spec.NetworkSpec.Vcn.Skip == *common.Bool(true) {
187189
if c.Spec.NetworkSpec.Vcn.ID == common.String("") || c.Spec.NetworkSpec.Vcn.ID == nil {
188190
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "NetworkSpec.Vcn.ID"), c.Spec.NetworkSpec.Vcn.ID, "field is required"))
@@ -208,22 +210,24 @@ func (c *OCICluster) ValidateUpdate(old runtime.Object) (admission.Warnings, err
208210
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "NetworkSpec.Vcn.RouteTable.Skip"), c.Spec.NetworkSpec.Vcn.RouteTable.Skip, "field requires to be true when VCN is skipped"))
209211
}
210212

211-
// For each subnet if Skip field is True, ID field of Subnet should be specified
212-
// Also for each subnet if ID field is True, Skip field of Subnet should be true
213+
// For each subnet
213214
for _, subnet := range c.Spec.NetworkSpec.Vcn.Subnets {
215+
216+
// if Skip field is true, ID field of Subnet should also be specified
214217
if subnet.Skip == *common.Bool(true) {
215218
if subnet.ID == common.String("") || subnet.ID == nil {
216219
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "subnet.ID"), subnet.ID, "field is required"))
217220
}
218221
}
222+
// if ID field is specified, Skip field of Subnet should also be true
219223
if subnet.ID != common.String("") {
220224
if subnet.Skip != *common.Bool(true) {
221225
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "subnet.Skip"), subnet.Skip, "field requires to be true if Subnet ID is specified"))
222226
}
223227
}
224228
}
225229
} else {
226-
// If Skip field is False, for each subnet in VCN the Skip field of Subnet cannot be true
230+
// If Skip field of VCN is false, for each subnet in that VCN the Skip field of Subnet cannot be true
227231
for _, subnet := range c.Spec.NetworkSpec.Vcn.Subnets {
228232
if subnet.Skip == *common.Bool(true) {
229233
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "subnet.Skip"), subnet.Skip, "field cannot be true when VCN is not skipped"))

api/v1beta2/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ type VCN struct {
910910
Name string `json:"name"`
911911

912912
// Skip specifies whether to skip creating VCN.
913+
// When is set to true, InternetGateway, NatGateway, ServiceGateway, RouteTable should be also have Skip set to true
913914
// +optional
914915
Skip bool `json:"skip,omitempty"`
915916

@@ -1132,6 +1133,7 @@ type RemotePeeringConnection struct {
11321133
// InternetGateway is used to specify the options for creating internet gateway.
11331134
type InternetGateway struct {
11341135
// Skip specifies whether to skip creating internet gateway even if any one Subnet is public.
1136+
// In case of VCN being Skipped (Skip field of VCN set to true), this field should be true also
11351137
// +optional
11361138
Skip bool `json:"skip,omitempty"`
11371139

@@ -1143,6 +1145,7 @@ type InternetGateway struct {
11431145
// NATGateway is used to specify the options for creating NAT gateway.
11441146
type NATGateway struct {
11451147
// Skip specifies whether to skip creating NAT gateway even if any one Subnet is private.
1148+
// In case of VCN being Skipped (Skip field of VCN set to true), this field should be true also
11461149
// +optional
11471150
Skip bool `json:"skip,omitempty"`
11481151

@@ -1154,6 +1157,7 @@ type NATGateway struct {
11541157
// ServiceGateway is used to specify the options for creating Service gateway.
11551158
type ServiceGateway struct {
11561159
// Skip specifies whether to skip creating Service gateway.
1160+
// In case of VCN being Skipped (Skip field of VCN set to true), this field should be true also
11571161
// +optional
11581162
Skip bool `json:"skip,omitempty"`
11591163

@@ -1165,6 +1169,7 @@ type ServiceGateway struct {
11651169
// RouteTable is used to specify the options for creating Route table.
11661170
type RouteTable struct {
11671171
// Skip specifies whether to skip creating Route table.
1172+
// In case of VCN being Skipped (Skip field of VCN set to true), this field should be true also
11681173
// +optional
11691174
Skip bool `json:"skip,omitempty"`
11701175

0 commit comments

Comments
 (0)