Skip to content

Commit 7e08d67

Browse files
committed
Apply review corrections
Signed-off-by: Borja Clemente <bclement@redhat.com>
1 parent e3e4196 commit 7e08d67

22 files changed

+56
-49
lines changed

api/v1beta1/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
"k8s.io/apimachinery/pkg/util/sets"
2121

22-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
22+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2323
)
2424

2525
// AWSResourceReference is a reference to a specific AWS resource by ID or filters.
@@ -165,7 +165,7 @@ type Instance struct {
165165
IAMProfile string `json:"iamProfile,omitempty"`
166166

167167
// Addresses contains the AWS instance associated addresses.
168-
Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"`
168+
Addresses []clusterv1beta1.MachineAddress `json:"addresses,omitempty"`
169169

170170
// The private IPv4 address assigned to the instance.
171171
PrivateIP *string `json:"privateIp,omitempty"`

api/v1beta2/awscluster_webhook_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"sigs.k8s.io/cluster-api-provider-aws/v2/feature"
3535
"sigs.k8s.io/cluster-api-provider-aws/v2/util/defaulting"
3636
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
37-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3837
)
3938

4039
func TestAWSClusterDefault(t *testing.T) {
@@ -983,7 +982,7 @@ func TestAWSClusterValidateUpdate(t *testing.T) {
983982
name: "removal of externally managed annotation is not allowed",
984983
oldCluster: &AWSCluster{
985984
ObjectMeta: metav1.ObjectMeta{
986-
Annotations: map[string]string{clusterv1.ManagedByAnnotation: ""},
985+
Annotations: map[string]string{clusterv1beta1.ManagedByAnnotation: ""},
987986
},
988987
},
989988
newCluster: &AWSCluster{},
@@ -994,7 +993,7 @@ func TestAWSClusterValidateUpdate(t *testing.T) {
994993
oldCluster: &AWSCluster{},
995994
newCluster: &AWSCluster{
996995
ObjectMeta: metav1.ObjectMeta{
997-
Annotations: map[string]string{clusterv1.ManagedByAnnotation: ""},
996+
Annotations: map[string]string{clusterv1beta1.ManagedByAnnotation: ""},
998997
},
999998
},
1000999
wantErr: false,

bootstrap/eks/controllers/eksconfig_controller.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/pkg/errors"
2626
corev1 "k8s.io/api/core/v1"
2727
apierrors "k8s.io/apimachinery/pkg/api/errors"
28-
"k8s.io/apimachinery/pkg/api/meta"
2928
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3029
"k8s.io/apimachinery/pkg/runtime"
3130
"k8s.io/apimachinery/pkg/types"
@@ -205,11 +204,11 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
205204
}
206205
}
207206

208-
if cluster.Spec.ControlPlaneRef.Name == "" || cluster.Spec.ControlPlaneRef.Kind != "AWSManagedControlPlane" {
207+
if !cluster.Spec.ControlPlaneRef.IsDefined() || cluster.Spec.ControlPlaneRef.Kind != "AWSManagedControlPlane" {
209208
return errors.New("Cluster's controlPlaneRef needs to be an AWSManagedControlPlane in order to use the EKS bootstrap provider")
210209
}
211210

212-
if !meta.IsStatusConditionTrue(cluster.GetConditions(), string(clusterv1beta1.InfrastructureReadyCondition)) {
211+
if !ptr.Deref(cluster.Status.Initialization.InfrastructureProvisioned, false) {
213212
log.Info("Cluster infrastructure is not ready")
214213
v1beta1conditions.MarkFalse(config,
215214
eksbootstrapv1.DataSecretAvailableCondition,
@@ -218,7 +217,7 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
218217
return nil
219218
}
220219

221-
if !meta.IsStatusConditionTrue(cluster.GetConditions(), string(clusterv1beta1.ControlPlaneInitializedCondition)) {
220+
if !ptr.Deref(cluster.Status.Initialization.ControlPlaneInitialized, false) {
222221
log.Info("Control Plane has not yet been initialized")
223222
v1beta1conditions.MarkFalse(config, eksbootstrapv1.DataSecretAvailableCondition, eksbootstrapv1.WaitingForControlPlaneInitializationReason, clusterv1beta1.ConditionSeverityInfo, "")
224223
return nil
@@ -373,7 +372,7 @@ func (r *EKSConfigReconciler) MachineToBootstrapMapFunc(_ context.Context, o cli
373372
if !ok {
374373
klog.Errorf("Expected a Machine but got a %T", o)
375374
}
376-
if m.Spec.Bootstrap.ConfigRef.Name != "" && m.Spec.Bootstrap.ConfigRef.APIGroup == eksbootstrapv1.GroupVersion.Group && m.Spec.Bootstrap.ConfigRef.Kind == eksConfigKind {
375+
if m.Spec.Bootstrap.ConfigRef.IsDefined() && m.Spec.Bootstrap.ConfigRef.APIGroup == eksbootstrapv1.GroupVersion.Group && m.Spec.Bootstrap.ConfigRef.Kind == eksConfigKind {
377376
name := client.ObjectKey{Namespace: m.Namespace, Name: m.Spec.Bootstrap.ConfigRef.Name}
378377
result = append(result, ctrl.Request{NamespacedName: name})
379378
}
@@ -390,7 +389,7 @@ func (r *EKSConfigReconciler) MachinePoolToBootstrapMapFunc(_ context.Context, o
390389
klog.Errorf("Expected a MachinePool but got a %T", o)
391390
}
392391
configRef := m.Spec.Template.Spec.Bootstrap.ConfigRef
393-
if configRef.Name != "" && configRef.APIGroup == eksbootstrapv1.GroupVersion.Group && configRef.Kind == eksConfigKind {
392+
if configRef.IsDefined() && configRef.APIGroup == eksbootstrapv1.GroupVersion.Group && configRef.Kind == eksConfigKind {
394393
name := client.ObjectKey{Namespace: m.Namespace, Name: configRef.Name}
395394
result = append(result, ctrl.Request{NamespacedName: name})
396395
}
@@ -421,7 +420,7 @@ func (r *EKSConfigReconciler) ClusterToEKSConfigs(_ context.Context, o client.Ob
421420
}
422421

423422
for _, m := range machineList.Items {
424-
if m.Spec.Bootstrap.ConfigRef.Name != "" &&
423+
if m.Spec.Bootstrap.ConfigRef.IsDefined() &&
425424
m.Spec.Bootstrap.ConfigRef.APIGroup == eksbootstrapv1.GroupVersion.Group &&
426425
m.Spec.Bootstrap.ConfigRef.Kind == eksConfigKind {
427426
name := client.ObjectKey{Namespace: m.Namespace, Name: m.Spec.Bootstrap.ConfigRef.Name}

controllers/awscluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func (r *AWSClusterReconciler) dependencyCount(ctx context.Context, clusterScope
487487

488488
listOptions := []client.ListOption{
489489
client.InNamespace(namespace),
490-
client.MatchingLabels(map[string]string{clusterv1.ClusterNameLabel: clusterName}),
490+
client.MatchingLabels(map[string]string{clusterv1beta1.ClusterNameLabel: clusterName}),
491491
}
492492

493493
machines := &infrav1.AWSMachineList{}

controlplane/eks/controllers/awsmanagedcontrolplane_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ func (r *AWSManagedControlPlaneReconciler) dependencyCount(ctx context.Context,
469469

470470
listOptions := []client.ListOption{
471471
client.InNamespace(namespace),
472-
client.MatchingLabels(map[string]string{clusterv1.ClusterNameLabel: clusterName}),
472+
client.MatchingLabels(map[string]string{clusterv1beta1.ClusterNameLabel: clusterName}),
473473
}
474474

475475
dependencies := 0

exp/api/v1beta2/awsfargateprofile_webhook.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3131

3232
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/eks"
33-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
33+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3434
)
3535

3636
const (
@@ -53,8 +53,10 @@ func (r *AWSFargateProfile) SetupWebhookWithManager(mgr ctrl.Manager) error {
5353

5454
type awsFargateProfileWebhook struct{}
5555

56-
var _ webhook.CustomDefaulter = &awsFargateProfileWebhook{}
57-
var _ webhook.CustomValidator = &awsFargateProfileWebhook{}
56+
var (
57+
_ webhook.CustomDefaulter = &awsFargateProfileWebhook{}
58+
_ webhook.CustomValidator = &awsFargateProfileWebhook{}
59+
)
5860

5961
// Default will set default values for the AWSFargateProfile.
6062
func (*awsFargateProfileWebhook) Default(_ context.Context, obj runtime.Object) error {
@@ -66,7 +68,7 @@ func (*awsFargateProfileWebhook) Default(_ context.Context, obj runtime.Object)
6668
if r.Labels == nil {
6769
r.Labels = make(map[string]string)
6870
}
69-
r.Labels[clusterv1.ClusterNameLabel] = r.Spec.ClusterName
71+
r.Labels[clusterv1beta1.ClusterNameLabel] = r.Spec.ClusterName
7072

7173
if r.Spec.ProfileName == "" {
7274
name, err := eks.GenerateEKSName(r.Name, r.Namespace, maxProfileNameLength)

exp/api/v1beta2/awsfargateprofile_webhook_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
2828
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/eks"
2929
utildefaulting "sigs.k8s.io/cluster-api-provider-aws/v2/util/defaulting"
30-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
30+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3131
)
3232

3333
func TestAWSFargateProfileDefault(t *testing.T) {
@@ -40,7 +40,7 @@ func TestAWSFargateProfileDefault(t *testing.T) {
4040
g := NewWithT(t)
4141
err := (&awsFargateProfileWebhook{}).Default(context.Background(), fargate)
4242
g.Expect(err).NotTo(HaveOccurred())
43-
g.Expect(fargate.GetLabels()[clusterv1.ClusterNameLabel]).To(BeEquivalentTo(fargate.Spec.ClusterName))
43+
g.Expect(fargate.GetLabels()[clusterv1beta1.ClusterNameLabel]).To(BeEquivalentTo(fargate.Spec.ClusterName))
4444
name, err := eks.GenerateEKSName(fargate.Name, fargate.Namespace, maxProfileNameLength)
4545
g.Expect(err).NotTo(HaveOccurred())
4646
g.Expect(fargate.Spec.ProfileName).To(BeEquivalentTo(name))

exp/controllers/awsfargatepool_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/eks"
3737
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger"
3838
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
39-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
4039
"sigs.k8s.io/cluster-api/util"
4140
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
4241
"sigs.k8s.io/cluster-api/util/predicates"
@@ -202,7 +201,7 @@ func managedControlPlaneToFargateProfileMapFunc(c client.Client, log logger.Wrap
202201

203202
fargateProfileForClusterList := expinfrav1.AWSFargateProfileList{}
204203
if err := c.List(
205-
ctx, &fargateProfileForClusterList, client.InNamespace(clusterKey.Namespace), client.MatchingLabels{clusterv1.ClusterNameLabel: clusterKey.Name},
204+
ctx, &fargateProfileForClusterList, client.InNamespace(clusterKey.Namespace), client.MatchingLabels{clusterv1beta1.ClusterNameLabel: clusterKey.Name},
206205
); err != nil {
207206
log.Error(err, "couldn't list fargate profiles for cluster")
208207
return nil

exp/controllers/awsmachinepool_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@ func (r *AWSMachinePoolReconciler) reconcileNormal(ctx context.Context, machineP
374374

375375
if err := createAWSMachinesIfNotExists(ctx, awsMachineList, machinePoolScope.MachinePool, &machinePoolScope.AWSMachinePool.ObjectMeta, &machinePoolScope.AWSMachinePool.TypeMeta, asg, machinePoolScope.GetLogger(), r.Client, ec2Svc); err != nil {
376376
machinePoolScope.SetNotReady()
377-
v1beta1conditions.MarkFalse(machinePoolScope.AWSMachinePool, clusterv1.ReadyCondition, expinfrav1.AWSMachineCreationFailed, clusterv1beta1.ConditionSeverityWarning, "%s", err.Error())
377+
v1beta1conditions.MarkFalse(machinePoolScope.AWSMachinePool, clusterv1beta1.ReadyCondition, expinfrav1.AWSMachineCreationFailed, clusterv1beta1.ConditionSeverityWarning, "%s", err.Error())
378378
return ctrl.Result{}, fmt.Errorf("failed to create awsmachines: %w", err)
379379
}
380380

381381
if err := deleteOrphanedAWSMachines(ctx, awsMachineList, asg, machinePoolScope.GetLogger(), r.Client); err != nil {
382382
machinePoolScope.SetNotReady()
383-
v1beta1conditions.MarkFalse(machinePoolScope.AWSMachinePool, clusterv1.ReadyCondition, expinfrav1.AWSMachineDeletionFailed, clusterv1beta1.ConditionSeverityWarning, "%s", err.Error())
383+
v1beta1conditions.MarkFalse(machinePoolScope.AWSMachinePool, clusterv1beta1.ReadyCondition, expinfrav1.AWSMachineDeletionFailed, clusterv1beta1.ConditionSeverityWarning, "%s", err.Error())
384384
return ctrl.Result{}, fmt.Errorf("failed to clean up awsmachines: %w", err)
385385
}
386386
}

exp/controllers/rosamachinepool_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
"sigs.k8s.io/cluster-api/util"
4343
"sigs.k8s.io/cluster-api/util/annotations"
4444
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
45-
"sigs.k8s.io/cluster-api/util/patch"
45+
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
4646
"sigs.k8s.io/cluster-api/util/predicates"
4747
)
4848

@@ -145,8 +145,8 @@ func (r *ROSAMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Requ
145145
}
146146

147147
controllerutil.RemoveFinalizer(rosaMachinePool, expinfrav1.RosaMachinePoolFinalizer)
148-
return ctrl.Result{}, patchHelper.Patch(ctx, rosaMachinePool, patch.WithOwnedConditions{Conditions: []string{
149-
string(expinfrav1.RosaMachinePoolReadyCondition),
148+
return ctrl.Result{}, patchHelper.Patch(ctx, rosaMachinePool, patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{
149+
expinfrav1.RosaMachinePoolReadyCondition,
150150
}})
151151
}
152152

0 commit comments

Comments
 (0)