Skip to content

Commit 1034bb6

Browse files
committed
fix(deps): moving patch to v1beta1 patch
Signed-off-by: Suhas Agasthya <suhasagasthya@gmail.com>
1 parent 7294c03 commit 1034bb6

File tree

10 files changed

+46
-46
lines changed

10 files changed

+46
-46
lines changed

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-
"sigs.k8s.io/cluster-api/util/patch"
35+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(scope.CloudStackCluster, r.Client)
174+
csClusterPatcher, err := v1beta1patch.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: 11 additions & 11 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-
"sigs.k8s.io/cluster-api/util/patch"
38+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(dummies.CSMachine1, testEnv.Client)
161+
ph, err := v1beta1patch.NewHelper(dummies.CSMachine1, testEnv.Client)
162162
g.Expect(err).ToNot(HaveOccurred())
163163
dummies.CSMachine1.OwnerReferences = append(dummies.CSMachine1.OwnerReferences, metav1.OwnerReference{
164164
Kind: "Machine",
@@ -167,7 +167,7 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
167167
UID: "uniqueness",
168168
})
169169

170-
return ph.Patch(ctx, dummies.CSMachine1, patch.WithStatusObservedGeneration{})
170+
return ph.Patch(ctx, dummies.CSMachine1, v1beta1patch.WithStatusObservedGeneration{})
171171
}, timeout).Should(Succeed())
172172

173173
setClusterReady(g, testEnv.Client)
@@ -210,13 +210,13 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
210210

211211
// Set node ref on CAPI machine to simulate that the machine is operational.
212212
g.Eventually(func() error {
213-
ph, err := patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
213+
ph, err := v1beta1patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
214214
g.Expect(err).ToNot(HaveOccurred())
215215
dummies.CAPIMachine.Status.NodeRef = clusterv1.MachineNodeReference{
216-
Name: "test-node",
216+
Name: "test-node",
217217
}
218218

219-
return ph.Patch(ctx, dummies.CAPIMachine, patch.WithStatusObservedGeneration{})
219+
return ph.Patch(ctx, dummies.CAPIMachine, v1beta1patch.WithStatusObservedGeneration{})
220220
}, timeout).Should(Succeed())
221221

222222
// Reconcile again (it is running).
@@ -312,13 +312,13 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
312312
g.Expect(testEnv.Create(ctx, dummies.CAPIMachine)).To(Succeed())
313313
// Set the NodeRef on the CAPI machine to simulate that the machine is operational.
314314
g.Eventually(func() error {
315-
ph, err := patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
315+
ph, err := v1beta1patch.NewHelper(dummies.CAPIMachine, testEnv.Client)
316316
g.Expect(err).ToNot(HaveOccurred())
317317
dummies.CAPIMachine.Status.NodeRef = clusterv1.MachineNodeReference{
318-
Name: "test-node",
318+
Name: "test-node",
319319
}
320320

321-
return ph.Patch(ctx, dummies.CAPIMachine, patch.WithStatusObservedGeneration{})
321+
return ph.Patch(ctx, dummies.CAPIMachine, v1beta1patch.WithStatusObservedGeneration{})
322322
}, timeout).Should(Succeed())
323323
g.Expect(testEnv.Create(ctx, dummies.CSMachine1)).To(Succeed())
324324

@@ -330,7 +330,7 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
330330

331331
// Set owner ref from CAPI machine to CS machine and patch back the CS machine.
332332
g.Eventually(func() error {
333-
ph, err := patch.NewHelper(dummies.CSMachine1, testEnv.Client)
333+
ph, err := v1beta1patch.NewHelper(dummies.CSMachine1, testEnv.Client)
334334
g.Expect(err).ToNot(HaveOccurred())
335335
dummies.CSMachine1.OwnerReferences = append(dummies.CSMachine1.OwnerReferences, metav1.OwnerReference{
336336
Kind: "Machine",
@@ -342,7 +342,7 @@ func TestCloudStackMachineReconcilerIntegrationTests(t *testing.T) {
342342
// Set the instance state to running to simulate that the machine is operational.
343343
dummies.CSMachine1.Status.InstanceState = cloud.InstanceStateRunning
344344

345-
return ph.Patch(ctx, dummies.CSMachine1, patch.WithStatusObservedGeneration{})
345+
return ph.Patch(ctx, dummies.CSMachine1, v1beta1patch.WithStatusObservedGeneration{})
346346
}, timeout).Should(Succeed())
347347

348348
setClusterReady(g, testEnv.Client)

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/apimachinery/pkg/types"
2424
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
25-
"sigs.k8s.io/cluster-api/util/patch"
25+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
2626
"sigs.k8s.io/controller-runtime/pkg/client"
2727

2828
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -72,21 +72,21 @@ func checkCloudStackClusterReady(ctx context.Context, g *WithT, client client.Cl
7272
// setCAPIClusterReady patches the cluster with ready status true.
7373
func setCAPIClusterReady(g *WithT, client client.Client) {
7474
g.Eventually(func() error {
75-
ph, err := patch.NewHelper(dummies.CAPICluster, client)
75+
ph, err := v1beta1patch.NewHelper(dummies.CAPICluster, client)
7676
g.Expect(err).ToNot(HaveOccurred())
7777
*dummies.CAPICluster.Status.Initialization.InfrastructureProvisioned = true
7878

79-
return ph.Patch(ctx, dummies.CAPICluster, patch.WithStatusObservedGeneration{})
79+
return ph.Patch(ctx, dummies.CAPICluster, v1beta1patch.WithStatusObservedGeneration{})
8080
}, timeout).Should(Succeed())
8181
}
8282

8383
// setCloudStackClusterReady patches the cluster with ready status true.
8484
func setCloudStackClusterReady(g *WithT, client client.Client) {
8585
g.Eventually(func() error {
86-
ph, err := patch.NewHelper(dummies.CSCluster, client)
86+
ph, err := v1beta1patch.NewHelper(dummies.CSCluster, client)
8787
g.Expect(err).ToNot(HaveOccurred())
8888
dummies.CSCluster.Status.Ready = true
8989

90-
return ph.Patch(ctx, dummies.CSCluster, patch.WithStatusObservedGeneration{})
90+
return ph.Patch(ctx, dummies.CSCluster, v1beta1patch.WithStatusObservedGeneration{})
9191
}, timeout).Should(Succeed())
9292
}

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-
"sigs.k8s.io/cluster-api/util/patch"
25+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(params.CloudStackAffinityGroup, params.Client)
66+
helper, err := v1beta1patch.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 *patch.Helper
80+
patchHelper *v1beta1patch.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-
"sigs.k8s.io/cluster-api/util/patch"
29+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(params.CloudStackCluster, params.Client)
68+
helper, err := v1beta1patch.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 *patch.Helper
82+
patchHelper *v1beta1patch.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-
patch.WithOwnedConditions{Conditions: []string{
133-
clusterv1.ReadyCondition,
134-
string(infrav1.FailureDomainsReadyCondition),
132+
v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{
133+
clusterv1beta1.ReadyCondition,
134+
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-
"sigs.k8s.io/cluster-api/util/patch"
30+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(params.CloudStackFailureDomain, params.Client)
73+
helper, err := v1beta1patch.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 *patch.Helper
87+
patchHelper *v1beta1patch.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-
"sigs.k8s.io/cluster-api/util/patch"
27+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(params.CloudStackIsolatedNetwork, params.Client)
72+
helper, err := v1beta1patch.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 *patch.Helper
86+
patchHelper *v1beta1patch.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-
"sigs.k8s.io/cluster-api/util/patch"
36+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(params.CloudStackMachine, params.Client)
88+
helper, err := v1beta1patch.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 *patch.Helper
102+
patchHelper *v1beta1patch.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-
patch.WithOwnedConditions{Conditions: []string{
178-
clusterv1.ReadyCondition,
179-
string(infrav1.InstanceReadyCondition),
180-
string(infrav1.LoadBalancerAttachedCondition),
177+
v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{
178+
clusterv1beta1.ReadyCondition,
179+
infrav1.InstanceReadyCondition,
180+
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-
"sigs.k8s.io/cluster-api/util/patch"
9+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/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 := patch.NewHelper(params.CloudStackMachineTemplate, params.Client)
50+
helper, err := v1beta1patch.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 *patch.Helper
64+
patchHelper *v1beta1patch.Helper
6565

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

test/e2e/invalid_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"k8s.io/utils/ptr"
3232
controlplanev1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta2"
3333
"sigs.k8s.io/cluster-api/api/core/v1beta2"
34-
"sigs.k8s.io/cluster-api/util/patch"
34+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
3535
"sigs.k8s.io/controller-runtime/pkg/client"
3636

3737
"sigs.k8s.io/cluster-api/test/framework"
@@ -264,7 +264,7 @@ func upgradeMachineDeploymentInfrastructureRef(ctx context.Context, deployment *
264264
newInfraObjName := createNewInfrastructureRef(ctx, infraRef)
265265

266266
// Patch the new infra object's ref to the machine deployment
267-
patchHelper, err := patch.NewHelper(deployment, mgmtClient)
267+
patchHelper, err := v1beta1patch.NewHelper(deployment, mgmtClient)
268268
Expect(err).ToNot(HaveOccurred())
269269
infraRef.Name = newInfraObjName
270270
deployment.Spec.Template.Spec.InfrastructureRef = infraRef
@@ -281,7 +281,7 @@ func upgradeControlPlaneInfrastructureRef(ctx context.Context, controlPlane *con
281281
newInfraObjName := createNewInfrastructureRef(ctx, infraRef)
282282

283283
// Patch the control plane to use the new infrastructure ref
284-
patchHelper, err := patch.NewHelper(controlPlane, mgmtClient)
284+
patchHelper, err := v1beta1patch.NewHelper(controlPlane, mgmtClient)
285285
Expect(err).ToNot(HaveOccurred())
286286
infraRef.Name = newInfraObjName
287287
controlPlane.Spec.MachineTemplate.Spec.InfrastructureRef = infraRef

0 commit comments

Comments
 (0)