Skip to content

Commit 74993b3

Browse files
committed
fixes
1 parent 8aae577 commit 74993b3

File tree

61 files changed

+519
-486
lines changed

Some content is hidden

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

61 files changed

+519
-486
lines changed

.golangci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ linters:
117117
- pkg: github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1
118118
alias: nsxvpcv1
119119
# CABPK
120-
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1
120+
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2
121121
alias: bootstrapv1
122+
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1
123+
alias: bootstrapv1beta1
122124
# KCP
123-
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1
125+
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2
124126
alias: controlplanev1
125127
# CAPI
126128
- pkg: sigs.k8s.io/cluster-api/api/v1beta2
@@ -201,6 +203,9 @@ linters:
201203
- linters:
202204
- staticcheck
203205
text: 'SA1019: "sigs.k8s.io/cluster-api-provider-vsphere/apis/(v1alpha3|v1alpha4)" is deprecated: This package will be removed in one of the next releases.'
206+
- linters:
207+
- staticcheck
208+
text: 'SA1019: "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/.*" is deprecated'
204209
- linters:
205210
- revive
206211
text: 'exported: exported method .*\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported'

controllers/clustermodule_reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ func (r Reconciler) PopulateWatchesOnController(mgr manager.Manager, controller
277277
func (r Reconciler) fetchMachineOwnerObjects(ctx context.Context, clusterCtx *capvcontext.ClusterContext) (map[string]clustermodule.Wrapper, error) {
278278
objects := map[string]clustermodule.Wrapper{}
279279

280-
name, ok := clusterCtx.VSphereCluster.GetLabels()[clusterv1beta1.ClusterNameLabel]
280+
name, ok := clusterCtx.VSphereCluster.GetLabels()[clusterv1.ClusterNameLabel]
281281
if !ok {
282282
return nil, errors.Errorf("failed to get Cluster name from VSphereCluster: missing cluster name label")
283283
}
284284

285-
labels := map[string]string{clusterv1beta1.ClusterNameLabel: name}
285+
labels := map[string]string{clusterv1.ClusterNameLabel: name}
286286
kcpList := &controlplanev1.KubeadmControlPlaneList{}
287287
if err := r.Client.List(
288288
ctx, kcpList,

controllers/clustermodule_reconciler_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/pkg/errors"
2626
"github.com/stretchr/testify/mock"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
28+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
2929
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2"
3030
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
3131
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -518,15 +518,15 @@ func TestReconciler_fetchMachineOwnerObjects(t *testing.T) {
518518
})
519519
}
520520

521-
func machineDeployment(name, namespace, cluster string) *clusterv1beta1.MachineDeployment {
522-
return &clusterv1beta1.MachineDeployment{
521+
func machineDeployment(name, namespace, cluster string) *clusterv1.MachineDeployment {
522+
return &clusterv1.MachineDeployment{
523523
TypeMeta: metav1.TypeMeta{
524524
Kind: "MachineDeployment",
525525
},
526526
ObjectMeta: metav1.ObjectMeta{
527527
Name: name,
528528
Namespace: namespace,
529-
Labels: map[string]string{clusterv1beta1.ClusterNameLabel: cluster},
529+
Labels: map[string]string{clusterv1.ClusterNameLabel: cluster},
530530
},
531531
}
532532
}
@@ -539,7 +539,7 @@ func controlPlane(name, namespace, cluster string) *controlplanev1.KubeadmContro
539539
ObjectMeta: metav1.ObjectMeta{
540540
Name: name,
541541
Namespace: namespace,
542-
Labels: map[string]string{clusterv1beta1.ClusterNameLabel: cluster},
542+
Labels: map[string]string{clusterv1.ClusterNameLabel: cluster},
543543
},
544544
}
545545
}

controllers/controllers_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3131
"k8s.io/client-go/kubernetes/scheme"
3232
"k8s.io/utils/ptr"
33-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
33+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3434
"sigs.k8s.io/cluster-api/controllers/clustercache"
3535
"sigs.k8s.io/cluster-api/controllers/remote"
3636
ctrl "sigs.k8s.io/controller-runtime"
@@ -67,7 +67,7 @@ func TestMain(m *testing.M) {
6767

6868
func setup() {
6969
utilruntime.Must(infrav1.AddToScheme(scheme.Scheme))
70-
utilruntime.Must(clusterv1beta1.AddToScheme(scheme.Scheme))
70+
utilruntime.Must(clusterv1.AddToScheme(scheme.Scheme))
7171
utilruntime.Must(vmwarev1.AddToScheme(scheme.Scheme))
7272

7373
testEnv = helpers.NewTestEnvironment(ctx)

controllers/vmware/controllers_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3232
"k8s.io/client-go/kubernetes/scheme"
3333
"k8s.io/utils/ptr"
34-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
34+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3535
"sigs.k8s.io/cluster-api/controllers/clustercache"
3636
"sigs.k8s.io/cluster-api/controllers/remote"
3737
ctrl "sigs.k8s.io/controller-runtime"
@@ -69,7 +69,7 @@ func TestMain(m *testing.M) {
6969

7070
func setup(ctx context.Context) (*helpers.TestEnvironment, clustercache.ClusterCache) {
7171
utilruntime.Must(infrav1.AddToScheme(scheme.Scheme))
72-
utilruntime.Must(clusterv1beta1.AddToScheme(scheme.Scheme))
72+
utilruntime.Must(clusterv1.AddToScheme(scheme.Scheme))
7373
utilruntime.Must(vmwarev1.AddToScheme(scheme.Scheme))
7474

7575
testEnv := helpers.NewTestEnvironment(ctx)

controllers/vmware/test/controllers_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"k8s.io/client-go/kubernetes/scheme"
3535
"k8s.io/client-go/rest"
3636
"k8s.io/klog/v2"
37-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
37+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3838
ctrl "sigs.k8s.io/controller-runtime"
3939
"sigs.k8s.io/controller-runtime/pkg/envtest"
4040
logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -68,7 +68,7 @@ func TestAPIs(t *testing.T) {
6868
}
6969

7070
func getTestEnv() (*envtest.Environment, *rest.Config) {
71-
utilruntime.Must(clusterv1beta1.AddToScheme(scheme.Scheme))
71+
utilruntime.Must(clusterv1.AddToScheme(scheme.Scheme))
7272
utilruntime.Must(vmwarev1.AddToScheme(scheme.Scheme))
7373

7474
// Get the root of the current file to use in CRD paths.

controllers/vmware/test/controllers_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"k8s.io/client-go/rest"
3535
"k8s.io/klog/v2"
3636
"k8s.io/utils/ptr"
37-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
37+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3838
"sigs.k8s.io/controller-runtime/pkg/cache"
3939
"sigs.k8s.io/controller-runtime/pkg/client"
4040
"sigs.k8s.io/controller-runtime/pkg/config"
@@ -62,7 +62,7 @@ const (
6262

6363
// newInfraCluster returns an Infra cluster with the same name as the target
6464
// cluster.
65-
func newInfraCluster(namespace string, cluster *clusterv1beta1.Cluster) client.Object {
65+
func newInfraCluster(namespace string, cluster *clusterv1.Cluster) client.Object {
6666
return &vmwarev1.VSphereCluster{
6767
ObjectMeta: metav1.ObjectMeta{
6868
Name: cluster.Name,
@@ -86,7 +86,7 @@ func newAnonInfraCluster(namespace string) client.Object {
8686

8787
// newInfraMachine creates an Infra machine with the same name as the target
8888
// machine.
89-
func newInfraMachine(namespace string, machine *clusterv1beta1.Machine) client.Object {
89+
func newInfraMachine(namespace string, machine *clusterv1.Machine) client.Object {
9090
return &vmwarev1.VSphereMachine{
9191
ObjectMeta: metav1.ObjectMeta{
9292
Name: machine.Name,
@@ -127,16 +127,16 @@ func dropNamespace(namespace *corev1.Namespace, k8sClient client.Client) {
127127

128128
// Creates and deploys a Cluster and VSphereCluster in order. Function does not
129129
// block on VSphereCluster creation.
130-
func deployCluster(namespace string, k8sClient client.Client) (client.ObjectKey, *clusterv1beta1.Cluster, client.Object) {
130+
func deployCluster(namespace string, k8sClient client.Client) (client.ObjectKey, *clusterv1.Cluster, client.Object) {
131131
// A finalizer is added to prevent it from being deleted until its
132132
// dependents are removed.
133-
cluster := &clusterv1beta1.Cluster{
133+
cluster := &clusterv1.Cluster{
134134
ObjectMeta: metav1.ObjectMeta{
135135
GenerateName: "test-",
136136
Namespace: namespace,
137137
Finalizers: []string{"test"},
138138
},
139-
Spec: clusterv1beta1.ClusterSpec{},
139+
Spec: clusterv1.ClusterSpec{},
140140
}
141141
Expect(k8sClient.Create(ctx, cluster)).To(Succeed())
142142

@@ -149,7 +149,7 @@ func deployCluster(namespace string, k8sClient client.Client) (client.ObjectKey,
149149
infraCluster := newInfraCluster(namespace, cluster)
150150
infraCluster.SetOwnerReferences([]metav1.OwnerReference{
151151
{
152-
APIVersion: clusterv1beta1.GroupVersion.String(),
152+
APIVersion: clusterv1.GroupVersion.String(),
153153
Kind: "Cluster",
154154
Name: cluster.Name,
155155
UID: cluster.UID,
@@ -162,28 +162,28 @@ func deployCluster(namespace string, k8sClient client.Client) (client.ObjectKey,
162162

163163
// Creates and deploys a CAPI Machine. Function does not block on Machine
164164
// creation.
165-
func deployCAPIMachine(namespace string, cluster *clusterv1beta1.Cluster, k8sClient client.Client) (client.ObjectKey, *clusterv1beta1.Machine) {
165+
func deployCAPIMachine(namespace string, cluster *clusterv1.Cluster, k8sClient client.Client) (client.ObjectKey, *clusterv1.Machine) {
166166
// A finalizer is added to prevent it from being deleted until its
167167
// dependents are removed.
168-
machine := &clusterv1beta1.Machine{
168+
machine := &clusterv1.Machine{
169169
ObjectMeta: metav1.ObjectMeta{
170170
GenerateName: "test-",
171171
Namespace: namespace,
172172
Finalizers: []string{"test"},
173173
Labels: map[string]string{
174-
clusterv1beta1.ClusterNameLabel: cluster.Name,
175-
clusterv1beta1.MachineControlPlaneLabel: "",
174+
clusterv1.ClusterNameLabel: cluster.Name,
175+
clusterv1.MachineControlPlaneLabel: "",
176176
},
177177
OwnerReferences: []metav1.OwnerReference{
178178
{
179-
APIVersion: clusterv1beta1.GroupVersion.String(),
179+
APIVersion: clusterv1.GroupVersion.String(),
180180
Kind: "Cluster",
181181
Name: cluster.Name,
182182
UID: cluster.UID,
183183
},
184184
},
185185
},
186-
Spec: clusterv1beta1.MachineSpec{
186+
Spec: clusterv1.MachineSpec{
187187
ClusterName: cluster.Name,
188188
},
189189
}
@@ -194,11 +194,11 @@ func deployCAPIMachine(namespace string, cluster *clusterv1beta1.Cluster, k8sCli
194194

195195
// Creates and deploys a VSphereMachine. Function does not block on Machine
196196
// creation.
197-
func deployInfraMachine(namespace string, machine *clusterv1beta1.Machine, finalizers []string, k8sClient client.Client) (client.ObjectKey, client.Object) {
197+
func deployInfraMachine(namespace string, machine *clusterv1.Machine, finalizers []string, k8sClient client.Client) (client.ObjectKey, client.Object) {
198198
infraMachine := newInfraMachine(namespace, machine)
199199
infraMachine.SetOwnerReferences([]metav1.OwnerReference{
200200
{
201-
APIVersion: clusterv1beta1.GroupVersion.String(),
201+
APIVersion: clusterv1.GroupVersion.String(),
202202
Kind: "Machine",
203203
Name: machine.Name,
204204
UID: machine.UID,
@@ -212,7 +212,7 @@ func deployInfraMachine(namespace string, machine *clusterv1beta1.Machine, final
212212

213213
// Updates the InfrastructureRef of a CAPI Cluster to a VSphereCluster. Function
214214
// does not block on update success.
215-
func updateClusterInfraRef(cluster *clusterv1beta1.Cluster, infraCluster client.Object, k8sClient client.Client) {
215+
func updateClusterInfraRef(cluster *clusterv1.Cluster, infraCluster client.Object, k8sClient client.Client) {
216216
cluster.Spec.InfrastructureRef = &corev1.ObjectReference{
217217
APIVersion: infraCluster.GetObjectKind().GroupVersionKind().GroupVersion().String(),
218218
Kind: infraCluster.GetObjectKind().GroupVersionKind().Kind,
@@ -551,13 +551,13 @@ var _ = Describe("Reconciliation tests", func() {
551551
By("Create the CAPI Machine and wait for it to exist")
552552
// A finalizer is added to prevent it from being deleted until its
553553
// dependents are removed.
554-
machine := &clusterv1beta1.Machine{
554+
machine := &clusterv1.Machine{
555555
ObjectMeta: metav1.ObjectMeta{
556556
GenerateName: "test-",
557557
Namespace: ns.Name,
558558
Finalizers: []string{"test"},
559559
},
560-
Spec: clusterv1beta1.MachineSpec{
560+
Spec: clusterv1.MachineSpec{
561561
ClusterName: "crud",
562562
},
563563
}

controllers/vmware/vspherecluster_reconciler_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
utilfeature "k8s.io/component-base/featuregate/testing"
3131
"k8s.io/utils/ptr"
3232
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
33+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3334
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
3435
"sigs.k8s.io/controller-runtime/pkg/client"
3536
"sigs.k8s.io/controller-runtime/pkg/client/fake"
@@ -55,7 +56,7 @@ var _ = Describe("Cluster Controller Tests", func() {
5556
testIP = "127.0.0.1"
5657
)
5758
var (
58-
cluster *clusterv1beta1.Cluster
59+
cluster *clusterv1.Cluster
5960
vsphereCluster *vmwarev1.VSphereCluster
6061
vsphereMachine *vmwarev1.VSphereMachine
6162
clusterCtx *vmware.ClusterContext

controllers/vspherecluster_reconciler_test.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3131
"k8s.io/utils/ptr"
3232
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
33+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3334
deprecatedconditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
3435
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
3536
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -97,12 +98,12 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
9798
Expect(testEnv.Delete(ctx, instance)).To(Succeed())
9899
}()
99100

100-
capiCluster := &clusterv1beta1.Cluster{
101+
capiCluster := &clusterv1.Cluster{
101102
ObjectMeta: metav1.ObjectMeta{
102103
GenerateName: "test1-",
103104
Namespace: "default",
104105
},
105-
Spec: clusterv1beta1.ClusterSpec{
106+
Spec: clusterv1.ClusterSpec{
106107
InfrastructureRef: &corev1.ObjectReference{
107108
APIVersion: infrav1.GroupVersion.String(),
108109
Kind: "VsphereCluster",
@@ -127,7 +128,7 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
127128
Expect(err).ShouldNot(HaveOccurred())
128129
instance.OwnerReferences = append(instance.OwnerReferences, metav1.OwnerReference{
129130
Kind: "Cluster",
130-
APIVersion: clusterv1beta1.GroupVersion.String(),
131+
APIVersion: clusterv1.GroupVersion.String(),
131132
Name: capiCluster.Name,
132133
UID: "blah",
133134
})
@@ -166,12 +167,12 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
166167

167168
It("should error if secret is already owned by a different cluster", func() {
168169
ctx := context.Background()
169-
capiCluster := &clusterv1beta1.Cluster{
170+
capiCluster := &clusterv1.Cluster{
170171
ObjectMeta: metav1.ObjectMeta{
171172
GenerateName: "test1-",
172173
Namespace: "default",
173174
},
174-
Spec: clusterv1beta1.ClusterSpec{
175+
Spec: clusterv1.ClusterSpec{
175176
InfrastructureRef: &corev1.ObjectReference{
176177
APIVersion: infrav1.GroupVersion.String(),
177178
Kind: "VsphereCluster",
@@ -223,7 +224,7 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
223224
Eventually(func() bool {
224225
ph, err := patch.NewHelper(instance, testEnv)
225226
Expect(err).ShouldNot(HaveOccurred())
226-
instance.OwnerReferences = append(instance.OwnerReferences, metav1.OwnerReference{Kind: "Cluster", APIVersion: clusterv1beta1.GroupVersion.String(), Name: capiCluster.Name, UID: "blah"})
227+
instance.OwnerReferences = append(instance.OwnerReferences, metav1.OwnerReference{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String(), Name: capiCluster.Name, UID: "blah"})
227228
Expect(ph.Patch(ctx, instance, patch.WithStatusObservedGeneration{})).ShouldNot(HaveOccurred())
228229
return true
229230
}, timeout).Should(BeTrue())
@@ -250,12 +251,12 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
250251

251252
It("should remove vspherecluster finalizer if the secret does not exist", func() {
252253
ctx := context.Background()
253-
capiCluster := &clusterv1beta1.Cluster{
254+
capiCluster := &clusterv1.Cluster{
254255
ObjectMeta: metav1.ObjectMeta{
255256
GenerateName: "test1-",
256257
Namespace: "default",
257258
},
258-
Spec: clusterv1beta1.ClusterSpec{
259+
Spec: clusterv1.ClusterSpec{
259260
InfrastructureRef: &corev1.ObjectReference{
260261
APIVersion: infrav1.GroupVersion.String(),
261262
Kind: "VsphereCluster",
@@ -272,7 +273,7 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
272273
Name: "vsphere-test1",
273274
Namespace: "default",
274275
OwnerReferences: []metav1.OwnerReference{{
275-
APIVersion: clusterv1beta1.GroupVersion.String(),
276+
APIVersion: clusterv1.GroupVersion.String(),
276277
Kind: "Cluster",
277278
Name: capiCluster.Name,
278279
UID: capiCluster.UID,
@@ -348,7 +349,7 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
348349
Context("With Deployment Zones", func() {
349350
var (
350351
namespace *corev1.Namespace
351-
capiCluster *clusterv1beta1.Cluster
352+
capiCluster *clusterv1.Cluster
352353
instance *infrav1.VSphereCluster
353354
zoneOne *infrav1.VSphereDeploymentZone
354355
)
@@ -358,12 +359,12 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
358359
namespace, err = testEnv.CreateNamespace(ctx, "dz-test")
359360
Expect(err).NotTo(HaveOccurred())
360361

361-
capiCluster = &clusterv1beta1.Cluster{
362+
capiCluster = &clusterv1.Cluster{
362363
ObjectMeta: metav1.ObjectMeta{
363364
GenerateName: "test1-",
364365
Namespace: namespace.Name,
365366
},
366-
Spec: clusterv1beta1.ClusterSpec{
367+
Spec: clusterv1.ClusterSpec{
367368
InfrastructureRef: &corev1.ObjectReference{
368369
APIVersion: infrav1.GroupVersion.String(),
369370
Kind: "VSphereCluster",
@@ -394,7 +395,7 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
394395
Namespace: namespace.Name,
395396
OwnerReferences: []metav1.OwnerReference{{
396397
Kind: "Cluster",
397-
APIVersion: clusterv1beta1.GroupVersion.String(),
398+
APIVersion: clusterv1.GroupVersion.String(),
398399
Name: capiCluster.Name,
399400
UID: "blah",
400401
}},

0 commit comments

Comments
 (0)