@@ -94,7 +94,7 @@ func (c *OCICluster) ValidateCreate() (admission.Warnings, error) {
94
94
}
95
95
}
96
96
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
98
98
if c .Spec .NetworkSpec .Vcn .Skip == * common .Bool (true ) {
99
99
if c .Spec .NetworkSpec .Vcn .ID == common .String ("" ) || c .Spec .NetworkSpec .Vcn .ID == nil {
100
100
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) {
120
120
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" ))
121
121
}
122
122
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
125
124
for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
125
+
126
+ // if Skip field is true, ID field of Subnet should also be specified
126
127
if subnet .Skip == * common .Bool (true ) {
127
128
if subnet .ID == common .String ("" ) || subnet .ID == nil {
128
129
allErrs = append (allErrs , field .Invalid (field .NewPath ("spec" , "subnet.ID" ), subnet .ID , "field is required" ))
129
130
}
130
131
}
132
+ // if ID field is specified, Skip field of Subnet should also be true
131
133
if subnet .ID != common .String ("" ) {
132
134
if subnet .Skip != * common .Bool (true ) {
133
135
allErrs = append (allErrs , field .Invalid (field .NewPath ("spec" , "subnet.Skip" ), subnet .Skip , "field requires to be true if Subnet ID is specified" ))
134
136
}
135
137
}
136
138
}
137
139
} 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
139
141
for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
140
142
if subnet .Skip == * common .Bool (true ) {
141
143
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
182
184
allErrs = append (allErrs , field .Invalid (field .NewPath ("spec" , "compartmentId" ), c .Spec .CompartmentId , "field is immutable" ))
183
185
}
184
186
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
186
188
if c .Spec .NetworkSpec .Vcn .Skip == * common .Bool (true ) {
187
189
if c .Spec .NetworkSpec .Vcn .ID == common .String ("" ) || c .Spec .NetworkSpec .Vcn .ID == nil {
188
190
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
208
210
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" ))
209
211
}
210
212
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
213
214
for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
215
+
216
+ // if Skip field is true, ID field of Subnet should also be specified
214
217
if subnet .Skip == * common .Bool (true ) {
215
218
if subnet .ID == common .String ("" ) || subnet .ID == nil {
216
219
allErrs = append (allErrs , field .Invalid (field .NewPath ("spec" , "subnet.ID" ), subnet .ID , "field is required" ))
217
220
}
218
221
}
222
+ // if ID field is specified, Skip field of Subnet should also be true
219
223
if subnet .ID != common .String ("" ) {
220
224
if subnet .Skip != * common .Bool (true ) {
221
225
allErrs = append (allErrs , field .Invalid (field .NewPath ("spec" , "subnet.Skip" ), subnet .Skip , "field requires to be true if Subnet ID is specified" ))
222
226
}
223
227
}
224
228
}
225
229
} 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
227
231
for _ , subnet := range c .Spec .NetworkSpec .Vcn .Subnets {
228
232
if subnet .Skip == * common .Bool (true ) {
229
233
allErrs = append (allErrs , field .Invalid (field .NewPath ("spec" , "subnet.Skip" ), subnet .Skip , "field cannot be true when VCN is not skipped" ))
0 commit comments