Skip to content

Commit 7fcd3c3

Browse files
authored
Fix webhook panic when VPC is nil (#2038)
1 parent 2a3745e commit 7fcd3c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

api/v1beta2/ibmpowervscluster_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ func (r *IBMPowerVSCluster) validateIBMPowerVSClusterCreateInfraPrereq() (allErr
198198
allErrs = append(allErrs, field.Invalid(field.NewPath("spec.vpc"), r.Spec.VPC, "value of VPC is empty"))
199199
}
200200

201-
if r.Spec.VPC.Region == nil {
201+
if r.Spec.VPC != nil && r.Spec.VPC.Region == nil {
202202
allErrs = append(allErrs, field.Invalid(field.NewPath("spec.vpc.region"), r.Spec.VPC.Region, "value of VPC region is empty"))
203203
}
204204

205-
if r.Spec.VPC.Region != nil && !regionUtil.ValidateVPCRegion(*r.Spec.VPC.Region) {
205+
if r.Spec.VPC != nil && r.Spec.VPC.Region != nil && !regionUtil.ValidateVPCRegion(*r.Spec.VPC.Region) {
206206
allErrs = append(allErrs, field.Invalid(field.NewPath("spec.vpc.region"), r.Spec.VPC.Region, fmt.Sprintf("vpc region '%s' is not supported", *r.Spec.VPC.Region)))
207207
}
208208

0 commit comments

Comments
 (0)