@@ -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" ))
0 commit comments