Skip to content

Commit 4ddc9d7

Browse files
committed
Using v1beta1conditions and patch
1 parent 1440f12 commit 4ddc9d7

31 files changed

+210
-204
lines changed

.golangci.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,15 @@ linters:
103103
# CAPI
104104
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta1
105105
alias: clusterv1
106-
# CAPI exp
107-
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta1
108-
alias: expv1
106+
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions
107+
alias: v1beta1conditions
108+
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch
109+
alias: v1beta1patch
110+
- pkg: sigs.k8s.io/cluster-api/api/bootstrap/kubeadm/v1beta1
111+
alias: kubeadmv1
112+
# # CAPI exp
113+
# - pkg: sigs.k8s.io/cluster-api/api/core/v1beta1
114+
# alias: expv1
109115
# CAPZ
110116
- pkg: sigs.k8s.io/cluster-api-provider-azure/api/v1beta1
111117
alias: infrav1

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

azure/converters/resourcehealth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth"
2323
"k8s.io/utils/ptr"
2424
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
25-
"sigs.k8s.io/cluster-api/util/conditions"
25+
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
2626

2727
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
2828
)

azure/scope/cluster.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import (
3333
"k8s.io/utils/net"
3434
"k8s.io/utils/ptr"
3535
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
36-
"sigs.k8s.io/cluster-api/util/conditions"
37-
"sigs.k8s.io/cluster-api/util/patch"
36+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
37+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
3838
"sigs.k8s.io/controller-runtime/pkg/client"
3939

4040
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
@@ -93,7 +93,7 @@ func NewClusterScope(ctx context.Context, params ClusterScopeParams) (*ClusterSc
9393
params.Cache = &ClusterCache{}
9494
}
9595

96-
helper, err := patch.NewHelper(params.AzureCluster, params.Client)
96+
helper, err := v1beta1patch.NewHelper(params.AzureCluster, params.Client)
9797
if err != nil {
9898
return nil, errors.Errorf("failed to init patch helper: %v", err)
9999
}
@@ -112,7 +112,7 @@ func NewClusterScope(ctx context.Context, params ClusterScopeParams) (*ClusterSc
112112
// ClusterScope defines the basic context for an actuator to operate upon.
113113
type ClusterScope struct {
114114
Client client.Client
115-
patchHelper *patch.Helper
115+
patchHelper *v1beta1patch.Helper
116116
cache *ClusterCache
117117

118118
AzureClients
@@ -935,12 +935,12 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
935935
ctx, _, done := tele.StartSpanWithLogger(ctx, "scope.ClusterScope.PatchObject")
936936
defer done()
937937

938-
conditions.SetSummary(s.AzureCluster)
938+
v1beta1conditions.SetSummary(s.AzureCluster)
939939

940940
return s.patchHelper.Patch(
941941
ctx,
942942
s.AzureCluster,
943-
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
943+
v1beta1patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
944944
clusterv1.ReadyCondition,
945945
infrav1.ResourceGroupReadyCondition,
946946
infrav1.RouteTablesReadyCondition,
@@ -1126,35 +1126,35 @@ func (s *ClusterScope) DeleteLongRunningOperationState(name, service, futureType
11261126
func (s *ClusterScope) UpdateDeleteStatus(condition clusterv1.ConditionType, service string, err error) {
11271127
switch {
11281128
case err == nil:
1129-
conditions.MarkFalse(s.AzureCluster, condition, infrav1.DeletedReason, clusterv1.ConditionSeverityInfo, "%s successfully deleted", service)
1129+
v1beta1conditions.MarkFalse(s.AzureCluster, condition, infrav1.DeletedReason, clusterv1.ConditionSeverityInfo, "%s successfully deleted", service)
11301130
case azure.IsOperationNotDoneError(err):
1131-
conditions.MarkFalse(s.AzureCluster, condition, infrav1.DeletingReason, clusterv1.ConditionSeverityInfo, "%s deleting", service)
1131+
v1beta1conditions.MarkFalse(s.AzureCluster, condition, infrav1.DeletingReason, clusterv1.ConditionSeverityInfo, "%s deleting", service)
11321132
default:
1133-
conditions.MarkFalse(s.AzureCluster, condition, infrav1.DeletionFailedReason, clusterv1.ConditionSeverityError, "%s failed to delete. err: %s", service, err.Error())
1133+
v1beta1conditions.MarkFalse(s.AzureCluster, condition, infrav1.DeletionFailedReason, clusterv1.ConditionSeverityError, "%s failed to delete. err: %s", service, err.Error())
11341134
}
11351135
}
11361136

11371137
// UpdatePutStatus updates a condition on the AzureCluster status after a PUT operation.
11381138
func (s *ClusterScope) UpdatePutStatus(condition clusterv1.ConditionType, service string, err error) {
11391139
switch {
11401140
case err == nil:
1141-
conditions.MarkTrue(s.AzureCluster, condition)
1141+
v1beta1conditions.MarkTrue(s.AzureCluster, condition)
11421142
case azure.IsOperationNotDoneError(err):
1143-
conditions.MarkFalse(s.AzureCluster, condition, infrav1.CreatingReason, clusterv1.ConditionSeverityInfo, "%s creating or updating", service)
1143+
v1beta1conditions.MarkFalse(s.AzureCluster, condition, infrav1.CreatingReason, clusterv1.ConditionSeverityInfo, "%s creating or updating", service)
11441144
default:
1145-
conditions.MarkFalse(s.AzureCluster, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to create or update. err: %s", service, err.Error())
1145+
v1beta1conditions.MarkFalse(s.AzureCluster, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to create or update. err: %s", service, err.Error())
11461146
}
11471147
}
11481148

11491149
// UpdatePatchStatus updates a condition on the AzureCluster status after a PATCH operation.
11501150
func (s *ClusterScope) UpdatePatchStatus(condition clusterv1.ConditionType, service string, err error) {
11511151
switch {
11521152
case err == nil:
1153-
conditions.MarkTrue(s.AzureCluster, condition)
1153+
v1beta1conditions.MarkTrue(s.AzureCluster, condition)
11541154
case azure.IsOperationNotDoneError(err):
1155-
conditions.MarkFalse(s.AzureCluster, condition, infrav1.UpdatingReason, clusterv1.ConditionSeverityInfo, "%s updating", service)
1155+
v1beta1conditions.MarkFalse(s.AzureCluster, condition, infrav1.UpdatingReason, clusterv1.ConditionSeverityInfo, "%s updating", service)
11561156
default:
1157-
conditions.MarkFalse(s.AzureCluster, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to update. err: %s", service, err.Error())
1157+
v1beta1conditions.MarkFalse(s.AzureCluster, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to update. err: %s", service, err.Error())
11581158
}
11591159
}
11601160

azure/scope/machine.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"k8s.io/utils/ptr"
3131
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3232
"sigs.k8s.io/cluster-api/util"
33-
"sigs.k8s.io/cluster-api/util/conditions"
34-
"sigs.k8s.io/cluster-api/util/patch"
33+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
34+
v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
3535
"sigs.k8s.io/controller-runtime/pkg/client"
3636

3737
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
@@ -75,7 +75,7 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) {
7575
return nil, errors.New("azure machine is required when creating a MachineScope")
7676
}
7777

78-
helper, err := patch.NewHelper(params.AzureMachine, params.Client)
78+
helper, err := v1beta1patch.NewHelper(params.AzureMachine, params.Client)
7979
if err != nil {
8080
return nil, errors.Wrap(err, "failed to init patch helper")
8181
}
@@ -94,7 +94,7 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) {
9494
// MachineScope defines a scope defined around a machine and its cluster.
9595
type MachineScope struct {
9696
client client.Client
97-
patchHelper *patch.Helper
97+
patchHelper *v1beta1patch.Helper
9898

9999
azure.ClusterScoper
100100
Machine *clusterv1.Machine
@@ -611,7 +611,7 @@ func (m *MachineScope) SetFailureReason(v string) {
611611

612612
// SetConditionFalse sets the specified AzureMachine condition to false.
613613
func (m *MachineScope) SetConditionFalse(conditionType clusterv1.ConditionType, reason string, severity clusterv1.ConditionSeverity, message string) {
614-
conditions.MarkFalse(m.AzureMachine, conditionType, reason, severity, "%s", message)
614+
v1beta1conditions.MarkFalse(m.AzureMachine, conditionType, reason, severity, "%s", message)
615615
}
616616

617617
// SetAnnotation sets a key value annotation on the AzureMachine.
@@ -656,12 +656,12 @@ func (m *MachineScope) SetAddresses(addrs []corev1.NodeAddress) {
656656

657657
// PatchObject persists the machine spec and status.
658658
func (m *MachineScope) PatchObject(ctx context.Context) error {
659-
conditions.SetSummary(m.AzureMachine)
659+
v1beta1conditions.SetSummary(m.AzureMachine)
660660

661661
return m.patchHelper.Patch(
662662
ctx,
663663
m.AzureMachine,
664-
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
664+
v1beta1patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
665665
clusterv1.ReadyCondition,
666666
infrav1.VMRunningCondition,
667667
infrav1.AvailabilitySetReadyCondition,
@@ -789,35 +789,35 @@ func (m *MachineScope) DeleteLongRunningOperationState(name, service, futureType
789789
func (m *MachineScope) UpdateDeleteStatus(condition clusterv1.ConditionType, service string, err error) {
790790
switch {
791791
case err == nil:
792-
conditions.MarkFalse(m.AzureMachine, condition, infrav1.DeletedReason, clusterv1.ConditionSeverityInfo, "%s successfully deleted", service)
792+
v1beta1conditions.MarkFalse(m.AzureMachine, condition, infrav1.DeletedReason, clusterv1.ConditionSeverityInfo, "%s successfully deleted", service)
793793
case azure.IsOperationNotDoneError(err):
794-
conditions.MarkFalse(m.AzureMachine, condition, infrav1.DeletingReason, clusterv1.ConditionSeverityInfo, "%s deleting", service)
794+
v1beta1conditions.MarkFalse(m.AzureMachine, condition, infrav1.DeletingReason, clusterv1.ConditionSeverityInfo, "%s deleting", service)
795795
default:
796-
conditions.MarkFalse(m.AzureMachine, condition, infrav1.DeletionFailedReason, clusterv1.ConditionSeverityError, "%s failed to delete. err: %s", service, err.Error())
796+
v1beta1conditions.MarkFalse(m.AzureMachine, condition, infrav1.DeletionFailedReason, clusterv1.ConditionSeverityError, "%s failed to delete. err: %s", service, err.Error())
797797
}
798798
}
799799

800800
// UpdatePutStatus updates a condition on the AzureMachine status after a PUT operation.
801801
func (m *MachineScope) UpdatePutStatus(condition clusterv1.ConditionType, service string, err error) {
802802
switch {
803803
case err == nil:
804-
conditions.MarkTrue(m.AzureMachine, condition)
804+
v1beta1conditions.MarkTrue(m.AzureMachine, condition)
805805
case azure.IsOperationNotDoneError(err):
806-
conditions.MarkFalse(m.AzureMachine, condition, infrav1.CreatingReason, clusterv1.ConditionSeverityInfo, "%s creating or updating", service)
806+
v1beta1conditions.MarkFalse(m.AzureMachine, condition, infrav1.CreatingReason, clusterv1.ConditionSeverityInfo, "%s creating or updating", service)
807807
default:
808-
conditions.MarkFalse(m.AzureMachine, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to create or update. err: %s", service, err.Error())
808+
v1beta1conditions.MarkFalse(m.AzureMachine, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to create or update. err: %s", service, err.Error())
809809
}
810810
}
811811

812812
// UpdatePatchStatus updates a condition on the AzureMachine status after a PATCH operation.
813813
func (m *MachineScope) UpdatePatchStatus(condition clusterv1.ConditionType, service string, err error) {
814814
switch {
815815
case err == nil:
816-
conditions.MarkTrue(m.AzureMachine, condition)
816+
v1beta1conditions.MarkTrue(m.AzureMachine, condition)
817817
case azure.IsOperationNotDoneError(err):
818-
conditions.MarkFalse(m.AzureMachine, condition, infrav1.UpdatingReason, clusterv1.ConditionSeverityInfo, "%s updating", service)
818+
v1beta1conditions.MarkFalse(m.AzureMachine, condition, infrav1.UpdatingReason, clusterv1.ConditionSeverityInfo, "%s updating", service)
819819
default:
820-
conditions.MarkFalse(m.AzureMachine, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to update. err: %s", service, err.Error())
820+
v1beta1conditions.MarkFalse(m.AzureMachine, condition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s failed to update. err: %s", service, err.Error())
821821
}
822822
}
823823

0 commit comments

Comments
 (0)