Skip to content

Commit b17552a

Browse files
committed
adding nil checks to spec version
1 parent 13c0c2e commit b17552a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (r *AWSManagedControlPlane) validateEKSVersion(old *AWSManagedControlPlane)
213213
allErrs = append(allErrs, field.Invalid(path, *r.Spec.Version, err.Error()))
214214
}
215215

216-
if old != nil {
216+
if old != nil && old.Spec.Version != nil {
217217
oldV, err := parseEKSVersion(*old.Spec.Version)
218218
if err == nil && (v.Major() < oldV.Major() || v.Minor() < oldV.Minor()) {
219219
allErrs = append(allErrs, field.Invalid(path, *r.Spec.Version, "new version less than old version"))
@@ -236,6 +236,10 @@ func (r *AWSManagedControlPlane) validateEKSAddons() field.ErrorList {
236236
return allErrs
237237
}
238238

239+
if r.Spec.Version == nil {
240+
return allErrs
241+
}
242+
239243
path := field.NewPath("spec.version")
240244
v, err := parseEKSVersion(*r.Spec.Version)
241245
if err != nil {

0 commit comments

Comments
 (0)