@@ -41,8 +41,8 @@ import (
4141 "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger"
4242 "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/record"
4343 "sigs.k8s.io/cluster-api-provider-aws/v2/util/paused"
44- clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1 "
45- controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/ api/v1beta1 "
44+ controlplanev1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta2 "
45+ clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2 "
4646 "sigs.k8s.io/cluster-api/util"
4747 "sigs.k8s.io/cluster-api/util/predicates"
4848)
@@ -176,7 +176,7 @@ func (r *AWSMachineTemplateReconciler) getRegion(ctx context.Context, cluster *c
176176 }
177177
178178 // Get region from AWSCluster (standard EC2-based cluster)
179- if cluster .Spec .InfrastructureRef != nil && cluster .Spec .InfrastructureRef .Kind == "AWSCluster" {
179+ if cluster .Spec .InfrastructureRef . IsDefined () && cluster .Spec .InfrastructureRef .Kind == "AWSCluster" {
180180 awsCluster := & infrav1.AWSCluster {}
181181 if err := r .Get (ctx , client.ObjectKey {
182182 Namespace : cluster .Namespace ,
@@ -191,7 +191,7 @@ func (r *AWSMachineTemplateReconciler) getRegion(ctx context.Context, cluster *c
191191 }
192192
193193 // Get region from AWSManagedControlPlane (EKS cluster)
194- if cluster .Spec .ControlPlaneRef != nil && cluster .Spec .ControlPlaneRef .Kind == "AWSManagedControlPlane" {
194+ if cluster .Spec .ControlPlaneRef . IsDefined () && cluster .Spec .ControlPlaneRef .Kind == "AWSManagedControlPlane" {
195195 awsManagedCP := & ekscontrolplanev1.AWSManagedControlPlane {}
196196 if err := r .Get (ctx , client.ObjectKey {
197197 Namespace : cluster .Namespace ,
@@ -373,9 +373,10 @@ func (r *AWSMachineTemplateReconciler) getKubernetesVersion(ctx context.Context,
373373
374374 // Find MachineDeployments that reference this AWSMachineTemplate
375375 for _ , md := range machineDeploymentList .Items {
376- if version := ptr .Deref (md .Spec .Template .Spec .Version , "" ); md .Spec .Template .Spec .InfrastructureRef .Kind == "AWSMachineTemplate" &&
377- md .Spec .Template .Spec .InfrastructureRef .Name == template .Name && version != "" {
378- return version , nil
376+ if md .Spec .Template .Spec .InfrastructureRef .Kind == "AWSMachineTemplate" &&
377+ md .Spec .Template .Spec .InfrastructureRef .Name == template .Name &&
378+ md .Spec .Template .Spec .Version != "" {
379+ return md .Spec .Template .Spec .Version , nil
379380 }
380381 }
381382
@@ -387,8 +388,8 @@ func (r *AWSMachineTemplateReconciler) getKubernetesVersion(ctx context.Context,
387388
388389 // Find KubeadmControlPlanes that reference this AWSMachineTemplate
389390 for _ , kcp := range kcpList .Items {
390- if kcp .Spec .MachineTemplate .InfrastructureRef .Kind == "AWSMachineTemplate" &&
391- kcp .Spec .MachineTemplate .InfrastructureRef .Name == template .Name &&
391+ if kcp .Spec .MachineTemplate .Spec . InfrastructureRef .Kind == "AWSMachineTemplate" &&
392+ kcp .Spec .MachineTemplate .Spec . InfrastructureRef .Name == template .Name &&
392393 kcp .Spec .Version != "" {
393394 return kcp .Spec .Version , nil
394395 }
0 commit comments