Skip to content

Commit c9d8a92

Browse files
committed
Revert: moving patch to v1beta1 patch
Signed-off-by: Suhas Agasthya <suhasagasthya@gmail.com>
1 parent 58ad6bc commit c9d8a92

File tree

11 files changed

+44
-47
lines changed

11 files changed

+44
-47
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ issues:
191191
- text: "SA1019: scope.Cluster.Status.Deprecated.V1Beta1.Conditions is deprecated"
192192
linters:
193193
- staticcheck
194-
- text: "SA1019: \"sigs\\.k8s\\.io\\/cluster-api\\/util\\/deprecated\\/v1beta1\\/patch\" is deprecated"
195-
linters:
196-
- staticcheck
197194
- path: api/v1beta3/webhook_suite_test.go
198195
linters:
199196
- goimports

internal/controllers/cloudstackisolatednetwork_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3333
"sigs.k8s.io/cluster-api/util"
3434
"sigs.k8s.io/cluster-api/util/annotations"
35-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
35+
"sigs.k8s.io/cluster-api/util/patch"
3636
"sigs.k8s.io/cluster-api/util/predicates"
3737
ctrl "sigs.k8s.io/controller-runtime"
3838
"sigs.k8s.io/controller-runtime/pkg/builder"
@@ -171,7 +171,7 @@ func (r *CloudStackIsolatedNetworkReconciler) reconcileNormal(ctx context.Contex
171171

172172
// Setup isolated network, endpoint, egress, and load balancing.
173173
// Set endpoint of CloudStackCluster if it is not currently set. (uses patcher to do so)
174-
csClusterPatcher, err := v1beta1patch.NewHelper(scope.CloudStackCluster, r.Client)
174+
csClusterPatcher, err := patch.NewHelper(scope.CloudStackCluster, r.Client)
175175
if err != nil {
176176
return ctrl.Result{}, errors.Wrap(err, "setting up CloudStackCluster patcher")
177177
}

internal/controllers/cloudstackmachine_controller_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"k8s.io/client-go/tools/record"
3636
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3737
"sigs.k8s.io/cluster-api/util"
38-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
38+
"sigs.k8s.io/cluster-api/util/patch"
3939
ctrl "sigs.k8s.io/controller-runtime"
4040
"sigs.k8s.io/controller-runtime/pkg/client"
4141
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -158,7 +158,7 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
158158

159159
// Set owner ref from CAPI machine to CS machine and patch back the CS machine.
160160
g.Eventually(func() error {
161-
ph, err := v1beta1patch.NewHelper(dummies.CSMachine1, testEnv.Client)
161+
ph, err := patch.NewHelper(dummies.CSMachine1, testEnv.Client)
162162
g.Expect(err).ToNot(HaveOccurred())
163163
dummies.CSMachine1.OwnerReferences = append(dummies.CSMachine1.OwnerReferences, metav1.OwnerReference{
164164
Kind: "Machine",
@@ -172,7 +172,7 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
172172
dummies.CSMachine1.Labels[infrav1.FailureDomainLabelName] =
173173
infrav1.FailureDomainHashedMetaName(dummies.CSMachine1.Spec.FailureDomainName, dummies.CAPICluster.Name)
174174

175-
return ph.Patch(ctx, dummies.CSMachine1, v1beta1patch.WithStatusObservedGeneration{})
175+
return ph.Patch(ctx, dummies.CSMachine1, patch.WithStatusObservedGeneration{})
176176
}, timeout).Should(Succeed())
177177
// Mark both Cluster and CloudStackCluster ready (v1beta2 readiness semantics).
178178
markClustersReady(ctx, g, testEnv.Client, dummies.CAPICluster, dummies.CSCluster)
@@ -215,13 +215,13 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
215215

216216
// Set node ref on CAPI machine to simulate that the machine is operational.
217217
g.Eventually(func() error {
218-
ph, err := v1beta1patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
218+
ph, err := patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
219219
g.Expect(err).ToNot(HaveOccurred())
220220
dummies.CAPIMachine.Status.NodeRef = clusterv1.MachineNodeReference{
221221
Name: "test-node",
222222
}
223223

224-
return ph.Patch(ctx, dummies.CAPIMachine, v1beta1patch.WithStatusObservedGeneration{})
224+
return ph.Patch(ctx, dummies.CAPIMachine, patch.WithStatusObservedGeneration{})
225225
}, timeout).Should(Succeed())
226226

227227
// Reconcile again (it is running).
@@ -317,13 +317,13 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
317317
g.Expect(testEnv.Create(ctx, dummies.CAPIMachine)).To(Succeed())
318318
// Set the NodeRef on the CAPI machine to simulate that the machine is operational.
319319
g.Eventually(func() error {
320-
ph, err := v1beta1patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
320+
ph, err := patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
321321
g.Expect(err).ToNot(HaveOccurred())
322322
dummies.CAPIMachine.Status.NodeRef = clusterv1.MachineNodeReference{
323323
Name: "test-node",
324324
}
325325

326-
return ph.Patch(ctx, dummies.CAPIMachine, v1beta1patch.WithStatusObservedGeneration{})
326+
return ph.Patch(ctx, dummies.CAPIMachine, patch.WithStatusObservedGeneration{})
327327
}, timeout).Should(Succeed())
328328
g.Expect(testEnv.Create(ctx, dummies.CSMachine1)).To(Succeed())
329329

@@ -335,7 +335,7 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
335335

336336
// Set owner ref from CAPI machine to CS machine and patch back the CS machine.
337337
g.Eventually(func() error {
338-
ph, err := v1beta1patch.NewHelper(dummies.CSMachine1, testEnv.Client)
338+
ph, err := patch.NewHelper(dummies.CSMachine1, testEnv.Client)
339339
g.Expect(err).ToNot(HaveOccurred())
340340
dummies.CSMachine1.OwnerReferences = append(dummies.CSMachine1.OwnerReferences, metav1.OwnerReference{
341341
Kind: "Machine",
@@ -352,7 +352,7 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
352352
dummies.CSMachine1.Labels[infrav1.FailureDomainLabelName] =
353353
infrav1.FailureDomainHashedMetaName(dummies.CSMachine1.Spec.FailureDomainName, dummies.CAPICluster.Name)
354354

355-
return ph.Patch(ctx, dummies.CSMachine1, v1beta1patch.WithStatusObservedGeneration{})
355+
return ph.Patch(ctx, dummies.CSMachine1, patch.WithStatusObservedGeneration{})
356356
}, timeout).Should(Succeed())
357357

358358
// Mark clusters ready (replaces setClusterReady & checkClusterReady).

internal/controllers/helpers_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
. "github.com/onsi/gomega"
2323
"k8s.io/utils/ptr"
2424
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
25-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
25+
"sigs.k8s.io/cluster-api/util/patch"
2626
"sigs.k8s.io/controller-runtime/pkg/client"
2727

2828
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -31,24 +31,24 @@ import (
3131
// markClustersReady patches Cluster & CloudStackCluster status to satisfy controller readiness checks (v1beta2 semantics).
3232
func markClustersReady(ctx context.Context, g *WithT, c client.Client, cluster *clusterv1.Cluster, csCluster *infrav1.CloudStackCluster) {
3333
g.Eventually(func() error {
34-
ph, err := v1beta1patch.NewHelper(cluster, c)
34+
ph, err := patch.NewHelper(cluster, c)
3535
if err != nil {
3636
return err
3737
}
3838
if cluster.Status.Initialization.InfrastructureProvisioned == nil || !*cluster.Status.Initialization.InfrastructureProvisioned {
3939
cluster.Status.Initialization.InfrastructureProvisioned = ptr.To(true)
4040
}
41-
return ph.Patch(ctx, cluster, v1beta1patch.WithStatusObservedGeneration{})
41+
return ph.Patch(ctx, cluster, patch.WithStatusObservedGeneration{})
4242
}, timeout).Should(Succeed())
4343

4444
g.Eventually(func() error {
45-
ph, err := v1beta1patch.NewHelper(csCluster, c)
45+
ph, err := patch.NewHelper(csCluster, c)
4646
if err != nil {
4747
return err
4848
}
4949
if !csCluster.Status.Ready {
5050
csCluster.Status.Ready = true
5151
}
52-
return ph.Patch(ctx, csCluster, v1beta1patch.WithStatusObservedGeneration{})
52+
return ph.Patch(ctx, csCluster, patch.WithStatusObservedGeneration{})
5353
}, timeout).Should(Succeed())
5454
}

pkg/scope/affinitygroup.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/pkg/errors"
2323
"k8s.io/klog/v2"
2424
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
25-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
25+
"sigs.k8s.io/cluster-api/util/patch"
2626
"sigs.k8s.io/controller-runtime/pkg/client"
2727

2828
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -63,7 +63,7 @@ func NewAffinityGroupScope(params AffinityGroupScopeParams) (*AffinityGroupScope
6363
CSClientsProvider: params.CSClients,
6464
}
6565

66-
helper, err := v1beta1patch.NewHelper(params.CloudStackAffinityGroup, params.Client)
66+
helper, err := patch.NewHelper(params.CloudStackAffinityGroup, params.Client)
6767
if err != nil {
6868
return nil, errors.Wrap(err, "failed to init patch helper")
6969
}
@@ -77,7 +77,7 @@ func NewAffinityGroupScope(params AffinityGroupScopeParams) (*AffinityGroupScope
7777
type AffinityGroupScope struct {
7878
logger.Logger
7979
client client.Client
80-
patchHelper *v1beta1patch.Helper
80+
patchHelper *patch.Helper
8181

8282
Cluster *clusterv1.Cluster
8383
CloudStackFailureDomain *infrav1.CloudStackFailureDomain

pkg/scope/cluster.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2727
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
2828
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
29-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
29+
"sigs.k8s.io/cluster-api/util/patch"
3030
"sigs.k8s.io/controller-runtime/pkg/client"
3131

3232
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -65,7 +65,7 @@ func NewClusterScope(params ClusterScopeParams) (*ClusterScope, error) {
6565
controllerName: params.ControllerName,
6666
}
6767

68-
helper, err := v1beta1patch.NewHelper(params.CloudStackCluster, params.Client)
68+
helper, err := patch.NewHelper(params.CloudStackCluster, params.Client)
6969
if err != nil {
7070
return nil, errors.Wrap(err, "failed to init patch helper")
7171
}
@@ -79,7 +79,7 @@ func NewClusterScope(params ClusterScopeParams) (*ClusterScope, error) {
7979
type ClusterScope struct {
8080
logger.Logger
8181
client client.Client
82-
patchHelper *v1beta1patch.Helper
82+
patchHelper *patch.Helper
8383

8484
Cluster *clusterv1.Cluster
8585
CloudStackCluster *infrav1.CloudStackCluster
@@ -129,9 +129,9 @@ func (s *ClusterScope) PatchObject() error {
129129
return s.patchHelper.Patch(
130130
context.TODO(),
131131
s.CloudStackCluster,
132-
v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{
133-
clusterv1beta1.ReadyCondition,
134-
infrav1.FailureDomainsReadyCondition,
132+
patch.WithOwnedConditions{Conditions: []string{
133+
clusterv1.ReadyCondition,
134+
string(infrav1.FailureDomainsReadyCondition),
135135
}},
136136
)
137137
}

pkg/scope/failuredomain.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"k8s.io/apimachinery/pkg/runtime/schema"
2828
"k8s.io/klog/v2"
2929
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
30-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
30+
"sigs.k8s.io/cluster-api/util/patch"
3131
"sigs.k8s.io/controller-runtime/pkg/client"
3232

3333
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -70,7 +70,7 @@ func NewFailureDomainScope(params FailureDomainScopeParams) (*FailureDomainScope
7070
CSClientsProvider: params.CSClients,
7171
}
7272

73-
helper, err := v1beta1patch.NewHelper(params.CloudStackFailureDomain, params.Client)
73+
helper, err := patch.NewHelper(params.CloudStackFailureDomain, params.Client)
7474
if err != nil {
7575
return nil, errors.Wrap(err, "failed to init patch helper")
7676
}
@@ -84,7 +84,7 @@ func NewFailureDomainScope(params FailureDomainScopeParams) (*FailureDomainScope
8484
type FailureDomainScope struct {
8585
logger.Logger
8686
client client.Client
87-
patchHelper *v1beta1patch.Helper
87+
patchHelper *patch.Helper
8888

8989
Cluster *clusterv1.Cluster
9090
CloudStackFailureDomain *infrav1.CloudStackFailureDomain

pkg/scope/isolatednetwork.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"k8s.io/apimachinery/pkg/runtime/schema"
2525
"k8s.io/klog/v2"
2626
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
27-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
27+
"sigs.k8s.io/cluster-api/util/patch"
2828
"sigs.k8s.io/controller-runtime/pkg/client"
2929

3030
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -69,7 +69,7 @@ func NewIsolatedNetworkScope(params IsolatedNetworkScopeParams) (*IsolatedNetwor
6969
CSClientsProvider: params.CSClients,
7070
}
7171

72-
helper, err := v1beta1patch.NewHelper(params.CloudStackIsolatedNetwork, params.Client)
72+
helper, err := patch.NewHelper(params.CloudStackIsolatedNetwork, params.Client)
7373
if err != nil {
7474
return nil, errors.Wrap(err, "failed to init patch helper")
7575
}
@@ -83,7 +83,7 @@ func NewIsolatedNetworkScope(params IsolatedNetworkScopeParams) (*IsolatedNetwor
8383
type IsolatedNetworkScope struct {
8484
logger.Logger
8585
client client.Client
86-
patchHelper *v1beta1patch.Helper
86+
patchHelper *patch.Helper
8787

8888
Cluster *clusterv1.Cluster
8989
CloudStackCluster *infrav1.CloudStackCluster

pkg/scope/machinescope.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"sigs.k8s.io/cluster-api/util"
3434
"sigs.k8s.io/cluster-api/util/annotations"
3535
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
36-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
36+
"sigs.k8s.io/cluster-api/util/patch"
3737
"sigs.k8s.io/controller-runtime/pkg/client"
3838

3939
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -85,7 +85,7 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) {
8585
CSClientsProvider: params.CSClients,
8686
}
8787

88-
helper, err := v1beta1patch.NewHelper(params.CloudStackMachine, params.Client)
88+
helper, err := patch.NewHelper(params.CloudStackMachine, params.Client)
8989
if err != nil {
9090
return nil, errors.Wrap(err, "failed to init patch helper")
9191
}
@@ -99,7 +99,7 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) {
9999
type MachineScope struct {
100100
logger.Logger
101101
client client.Client
102-
patchHelper *v1beta1patch.Helper
102+
patchHelper *patch.Helper
103103

104104
Cluster *clusterv1.Cluster
105105
CloudStackCluster *infrav1.CloudStackCluster
@@ -174,10 +174,10 @@ func (s *MachineScope) PatchObject() error {
174174
return s.patchHelper.Patch(
175175
context.TODO(),
176176
s.CloudStackMachine,
177-
v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{
178-
clusterv1beta1.ReadyCondition,
179-
infrav1.InstanceReadyCondition,
180-
infrav1.LoadBalancerAttachedCondition,
177+
patch.WithOwnedConditions{Conditions: []string{
178+
clusterv1.ReadyCondition,
179+
string(infrav1.InstanceReadyCondition),
180+
string(infrav1.LoadBalancerAttachedCondition),
181181
}},
182182
)
183183
}

pkg/scope/machinetemplate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/pkg/errors"
77
"k8s.io/klog/v2"
88
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
9-
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
9+
"sigs.k8s.io/cluster-api/util/patch"
1010
"sigs.k8s.io/controller-runtime/pkg/client"
1111

1212
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -47,7 +47,7 @@ func NewMachineTemplateScope(params MachineTemplateScopeParams) (*MachineTemplat
4747
CSClientsProvider: params.CSClients,
4848
}
4949

50-
helper, err := v1beta1patch.NewHelper(params.CloudStackMachineTemplate, params.Client)
50+
helper, err := patch.NewHelper(params.CloudStackMachineTemplate, params.Client)
5151
if err != nil {
5252
return nil, errors.Wrap(err, "failed to init patch helper")
5353
}
@@ -61,7 +61,7 @@ func NewMachineTemplateScope(params MachineTemplateScopeParams) (*MachineTemplat
6161
type MachineTemplateScope struct {
6262
logger.Logger
6363
client client.Client
64-
patchHelper *v1beta1patch.Helper
64+
patchHelper *patch.Helper
6565

6666
Cluster *clusterv1.Cluster
6767
CloudStackMachineTemplate *infrav1.CloudStackMachineTemplate

0 commit comments

Comments
 (0)