Skip to content

Commit 858ae88

Browse files
authored
Merge pull request #3491 from chrischdi/pr-adapt-capi-alias-naming-conditions
🌱 Adjust import alias to align with CAPI migration recommendation
2 parents 2378bfb + 36caa2d commit 858ae88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+456
-456
lines changed

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ linters:
130130
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta1
131131
alias: clusterv1beta1
132132
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions
133-
alias: deprecatedconditions
133+
alias: v1beta1conditions
134134
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions/v1beta2
135-
alias: deprecatedv1beta2conditions
135+
alias: v1beta2conditions
136136
# CAPI addons
137137
- pkg: sigs.k8s.io/cluster-api/api/addons/v1beta2
138138
alias: addonsv1

controllers/clustermodule_reconciler.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2929
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3030
"sigs.k8s.io/cluster-api/util"
31-
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
32-
deprecatedv1beta2conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions/v1beta2"
31+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
32+
v1beta2conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions/v1beta2"
3333
ctrl "sigs.k8s.io/controller-runtime"
3434
"sigs.k8s.io/controller-runtime/pkg/client"
3535
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -69,9 +69,9 @@ func (r Reconciler) Reconcile(ctx context.Context, clusterCtx *capvcontext.Clust
6969
log := ctrl.LoggerFrom(ctx)
7070

7171
if !clustermodule.IsClusterCompatible(clusterCtx) {
72-
deprecatedconditions.MarkFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition, infrav1.VCenterVersionIncompatibleReason, clusterv1beta1.ConditionSeverityInfo,
72+
v1beta1conditions.MarkFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition, infrav1.VCenterVersionIncompatibleReason, clusterv1beta1.ConditionSeverityInfo,
7373
"vCenter version %s does not support cluster modules", clusterCtx.VSphereCluster.Status.VCenterVersion)
74-
deprecatedv1beta2conditions.Set(clusterCtx.VSphereCluster, metav1.Condition{
74+
v1beta2conditions.Set(clusterCtx.VSphereCluster, metav1.Condition{
7575
Type: infrav1.VSphereClusterClusterModulesReadyV1Beta2Condition,
7676
Status: metav1.ConditionFalse,
7777
Reason: infrav1.VSphereClusterModulesInvalidVCenterVersionV1Beta2Reason,
@@ -176,21 +176,21 @@ func (r Reconciler) Reconcile(ctx context.Context, clusterCtx *capvcontext.Clust
176176
} else {
177177
err = errors.New(generateClusterModuleErrorMessage(modErrs))
178178
}
179-
deprecatedconditions.MarkFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition, infrav1.ClusterModuleSetupFailedReason,
179+
v1beta1conditions.MarkFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition, infrav1.ClusterModuleSetupFailedReason,
180180
clusterv1beta1.ConditionSeverityWarning, "%s", generateClusterModuleErrorMessage(modErrs))
181-
deprecatedv1beta2conditions.Set(clusterCtx.VSphereCluster, metav1.Condition{
181+
v1beta2conditions.Set(clusterCtx.VSphereCluster, metav1.Condition{
182182
Type: infrav1.VSphereClusterClusterModulesReadyV1Beta2Condition,
183183
Status: metav1.ConditionFalse,
184184
Reason: infrav1.VSphereClusterClusterModulesNotReadyV1Beta2Reason,
185185
Message: generateClusterModuleErrorMessage(modErrs),
186186
})
187187
return reconcile.Result{}, err
188188
case len(modErrs) == 0 && len(clusterModuleSpecs) > 0:
189-
deprecatedconditions.MarkTrue(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)
189+
v1beta1conditions.MarkTrue(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)
190190
default:
191-
deprecatedconditions.Delete(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)
191+
v1beta1conditions.Delete(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)
192192
}
193-
deprecatedv1beta2conditions.Set(clusterCtx.VSphereCluster, metav1.Condition{
193+
v1beta2conditions.Set(clusterCtx.VSphereCluster, metav1.Condition{
194194
Type: infrav1.VSphereClusterClusterModulesReadyV1Beta2Condition,
195195
Status: metav1.ConditionTrue,
196196
Reason: infrav1.VSphereClusterClusterModulesReadyV1Beta2Reason,

controllers/clustermodule_reconciler_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
controlplanev1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta2"
2929
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
30-
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
30+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
3131
"sigs.k8s.io/controller-runtime/pkg/client"
3232

3333
infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1"
@@ -145,8 +145,8 @@ func TestReconciler_Reconcile(t *testing.T) {
145145
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ModuleUUID).To(gomega.BeElementOf(kcpUUID+"a", mdUUID+"a"))
146146
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[1].ModuleUUID).To(gomega.BeElementOf(kcpUUID+"a", mdUUID+"a"))
147147
// Check that condition got set.
148-
g.Expect(deprecatedconditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
149-
g.Expect(deprecatedconditions.IsTrue(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
148+
g.Expect(v1beta1conditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
149+
g.Expect(v1beta1conditions.IsTrue(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
150150
},
151151
},
152152
{
@@ -174,9 +174,9 @@ func TestReconciler_Reconcile(t *testing.T) {
174174
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ModuleUUID).To(gomega.BeElementOf(kcpUUID, mdUUID))
175175
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[1].ModuleUUID).To(gomega.BeElementOf(kcpUUID, mdUUID))
176176
// Check that condition got set.
177-
g.Expect(deprecatedconditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
178-
g.Expect(deprecatedconditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
179-
g.Expect(deprecatedconditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring(vCenter500err.Error()))
177+
g.Expect(v1beta1conditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
178+
g.Expect(v1beta1conditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
179+
g.Expect(v1beta1conditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring(vCenter500err.Error()))
180180
},
181181
},
182182
{
@@ -204,9 +204,9 @@ func TestReconciler_Reconcile(t *testing.T) {
204204
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ModuleUUID).To(gomega.BeElementOf(kcpUUID, mdUUID))
205205
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[1].ModuleUUID).To(gomega.BeElementOf(kcpUUID, mdUUID))
206206
// Check that condition got set.
207-
g.Expect(deprecatedconditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
208-
g.Expect(deprecatedconditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
209-
g.Expect(deprecatedconditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring(vCenter500err.Error()))
207+
g.Expect(v1beta1conditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
208+
g.Expect(v1beta1conditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
209+
g.Expect(v1beta1conditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring(vCenter500err.Error()))
210210
},
211211
},
212212
{
@@ -235,9 +235,9 @@ func TestReconciler_Reconcile(t *testing.T) {
235235
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ModuleUUID).To(gomega.BeElementOf(kcpUUID+"a", mdUUID))
236236
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[1].ModuleUUID).To(gomega.BeElementOf(kcpUUID+"a", mdUUID))
237237
// Check that condition got set.
238-
g.Expect(deprecatedconditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
239-
g.Expect(deprecatedconditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
240-
g.Expect(deprecatedconditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring(vCenter500err.Error()))
238+
g.Expect(v1beta1conditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
239+
g.Expect(v1beta1conditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
240+
g.Expect(v1beta1conditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring(vCenter500err.Error()))
241241
},
242242
},
243243
{
@@ -253,9 +253,9 @@ func TestReconciler_Reconcile(t *testing.T) {
253253
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ModuleUUID).To(gomega.Equal(mdUUID))
254254
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ControlPlane).To(gomega.BeFalse())
255255

256-
g.Expect(deprecatedconditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
257-
g.Expect(deprecatedconditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
258-
g.Expect(deprecatedconditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring("kcp"))
256+
g.Expect(v1beta1conditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
257+
g.Expect(v1beta1conditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
258+
g.Expect(v1beta1conditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring("kcp"))
259259
},
260260
},
261261
{
@@ -273,9 +273,9 @@ func TestReconciler_Reconcile(t *testing.T) {
273273
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ModuleUUID).To(gomega.Equal(kcpUUID))
274274
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules[0].ControlPlane).To(gomega.BeTrue())
275275

276-
g.Expect(deprecatedconditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
277-
g.Expect(deprecatedconditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
278-
g.Expect(deprecatedconditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring("md"))
276+
g.Expect(v1beta1conditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
277+
g.Expect(v1beta1conditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
278+
g.Expect(v1beta1conditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring("md"))
279279
},
280280
},
281281
{
@@ -289,9 +289,9 @@ func TestReconciler_Reconcile(t *testing.T) {
289289
haveError: false,
290290
customAssert: func(g *gomega.WithT, clusterCtx *capvcontext.ClusterContext) {
291291
g.Expect(clusterCtx.VSphereCluster.Spec.ClusterModules).To(gomega.BeEmpty())
292-
g.Expect(deprecatedconditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
293-
g.Expect(deprecatedconditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
294-
g.Expect(deprecatedconditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring("kcp"))
292+
g.Expect(v1beta1conditions.Has(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
293+
g.Expect(v1beta1conditions.IsFalse(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition)).To(gomega.BeTrue())
294+
g.Expect(v1beta1conditions.Get(clusterCtx.VSphereCluster, infrav1.ClusterModulesAvailableCondition).Message).To(gomega.ContainSubstring("kcp"))
295295
},
296296
},
297297
{

controllers/vmware/serviceaccount_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import (
3636
"sigs.k8s.io/cluster-api/controllers/clustercache"
3737
clusterutilv1 "sigs.k8s.io/cluster-api/util"
3838
"sigs.k8s.io/cluster-api/util/annotations"
39-
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
40-
deprecatedv1beta2conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions/v1beta2"
39+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
40+
v1beta2conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions/v1beta2"
4141
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
4242
"sigs.k8s.io/cluster-api/util/predicates"
4343
ctrl "sigs.k8s.io/controller-runtime"
@@ -207,17 +207,17 @@ func (r *ServiceAccountReconciler) patch(ctx context.Context, clusterCtx *vmware
207207
func (r *ServiceAccountReconciler) reconcileNormal(ctx context.Context, guestClusterCtx *vmwarecontext.GuestClusterContext) (_ reconcile.Result, reterr error) {
208208
defer func() {
209209
if reterr != nil {
210-
deprecatedconditions.MarkFalse(guestClusterCtx.VSphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition, vmwarev1.ProviderServiceAccountsReconciliationFailedReason,
210+
v1beta1conditions.MarkFalse(guestClusterCtx.VSphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition, vmwarev1.ProviderServiceAccountsReconciliationFailedReason,
211211
clusterv1beta1.ConditionSeverityWarning, "%v", reterr)
212-
deprecatedv1beta2conditions.Set(guestClusterCtx.VSphereCluster, metav1.Condition{
212+
v1beta2conditions.Set(guestClusterCtx.VSphereCluster, metav1.Condition{
213213
Type: vmwarev1.VSphereClusterProviderServiceAccountsReadyV1Beta2Condition,
214214
Status: metav1.ConditionFalse,
215215
Reason: vmwarev1.VSphereClusterProviderServiceAccountsNotReadyV1Beta2Reason,
216216
Message: reterr.Error(),
217217
})
218218
} else {
219-
deprecatedconditions.MarkTrue(guestClusterCtx.VSphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition)
220-
deprecatedv1beta2conditions.Set(guestClusterCtx.VSphereCluster, metav1.Condition{
219+
v1beta1conditions.MarkTrue(guestClusterCtx.VSphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition)
220+
v1beta2conditions.Set(guestClusterCtx.VSphereCluster, metav1.Condition{
221221
Type: vmwarev1.VSphereClusterProviderServiceAccountsReadyV1Beta2Condition,
222222
Status: metav1.ConditionTrue,
223223
Reason: vmwarev1.VSphereClusterProviderServiceAccountsReadyV1Beta2Reason,

controllers/vmware/serviceaccount_controller_intg_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"k8s.io/apimachinery/pkg/types"
3333
"k8s.io/utils/ptr"
3434
"sigs.k8s.io/cluster-api/controllers/clustercache"
35-
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
35+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
3636
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
3737
"sigs.k8s.io/controller-runtime/pkg/client"
3838

@@ -174,7 +174,7 @@ var _ = Describe("ProviderServiceAccount controller integration tests", func() {
174174
vsphereCluster := &vmwarev1.VSphereCluster{}
175175
key := client.ObjectKey{Namespace: intCtx.Namespace, Name: intCtx.VSphereCluster.GetName()}
176176
Expect(intCtx.Client.Get(ctx, key, vsphereCluster)).To(Succeed())
177-
Expect(deprecatedconditions.Has(vsphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition)).To(BeFalse())
177+
Expect(v1beta1conditions.Has(vsphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition)).To(BeFalse())
178178
})
179179
})
180180
})
@@ -196,7 +196,7 @@ var _ = Describe("ProviderServiceAccount controller integration tests", func() {
196196
vsphereCluster := &vmwarev1.VSphereCluster{}
197197
key := client.ObjectKey{Namespace: intCtx.Namespace, Name: intCtx.VSphereCluster.GetName()}
198198
Expect(intCtx.Client.Get(ctx, key, vsphereCluster)).To(Succeed())
199-
Expect(deprecatedconditions.Has(vsphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition)).To(BeFalse())
199+
Expect(v1beta1conditions.Has(vsphereCluster, vmwarev1.ProviderServiceAccountsReadyCondition)).To(BeFalse())
200200
})
201201
})
202202
})

controllers/vmware/serviceaccount_controller_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
apierrors "k8s.io/apimachinery/pkg/api/errors"
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
31-
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
31+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
3232
"sigs.k8s.io/controller-runtime/pkg/client"
3333

3434
vmwarev1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/vmware/v1beta1"
@@ -155,7 +155,7 @@ func assertRoleBinding(ctx context.Context, ctrlClient client.Client, namespace,
155155

156156
// assertProviderServiceAccountsCondition asserts the condition on the ProviderServiceAccount CR.
157157
func assertProviderServiceAccountsCondition(vCluster *vmwarev1.VSphereCluster, status corev1.ConditionStatus, message string, reason string, severity clusterv1beta1.ConditionSeverity) {
158-
c := deprecatedconditions.Get(vCluster, vmwarev1.ProviderServiceAccountsReadyCondition)
158+
c := v1beta1conditions.Get(vCluster, vmwarev1.ProviderServiceAccountsReadyCondition)
159159
Expect(c).NotTo(BeNil())
160160
Expect(c.Status).To(Equal(status))
161161
Expect(c.Reason).To(Equal(reason))

0 commit comments

Comments
 (0)