@@ -30,6 +30,7 @@ import (
30
30
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
31
31
clusterutilv1 "sigs.k8s.io/cluster-api/util"
32
32
"sigs.k8s.io/cluster-api/util/conditions"
33
+ v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
33
34
"sigs.k8s.io/cluster-api/util/finalizers"
34
35
"sigs.k8s.io/cluster-api/util/patch"
35
36
"sigs.k8s.io/cluster-api/util/paused"
@@ -102,6 +103,7 @@ func (r clusterIdentityReconciler) Reconcile(ctx context.Context, req reconcile.
102
103
103
104
if err := patchHelper .Patch (ctx , identity , patch.WithOwnedV1Beta2Conditions {Conditions : []string {
104
105
clusterv1 .PausedV1Beta2Condition ,
106
+ infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
105
107
}}); err != nil {
106
108
reterr = kerrors .NewAggregate ([]error {reterr , err })
107
109
}
@@ -119,12 +121,24 @@ func (r clusterIdentityReconciler) Reconcile(ctx context.Context, req reconcile.
119
121
}
120
122
if err := r .Client .Get (ctx , secretKey , secret ); err != nil {
121
123
conditions .MarkFalse (identity , infrav1 .CredentialsAvailableCondidtion , infrav1 .SecretNotAvailableReason , clusterv1 .ConditionSeverityWarning , err .Error ())
124
+ v1beta2conditions .Set (identity , metav1.Condition {
125
+ Type : infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
126
+ Status : metav1 .ConditionFalse ,
127
+ Reason : infrav1 .VSphereClusterIdentityCredentialsSecretNotAvailableV1Beta2Reason ,
128
+ Message : err .Error (),
129
+ })
122
130
return reconcile.Result {}, errors .Wrapf (err , "failed to get Secret %s" , klog .KRef (secretKey .Namespace , secretKey .Name ))
123
131
}
124
132
125
133
// If this secret is owned by a different VSphereClusterIdentity or a VSphereCluster, mark the identity as not ready and return an error.
126
134
if ! clusterutilv1 .IsOwnedByObject (secret , identity ) && pkgidentity .IsOwnedByIdentityOrCluster (secret .GetOwnerReferences ()) {
127
135
conditions .MarkFalse (identity , infrav1 .CredentialsAvailableCondidtion , infrav1 .SecretAlreadyInUseReason , clusterv1 .ConditionSeverityError , "secret being used by another Cluster/VSphereIdentity" )
136
+ v1beta2conditions .Set (identity , metav1.Condition {
137
+ Type : infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
138
+ Status : metav1 .ConditionFalse ,
139
+ Reason : infrav1 .VSphereClusterIdentityCredentialsSecretAlreadyInUseV1Beta2Reason ,
140
+ Message : "secret being used by another Cluster/VSphereIdentity" ,
141
+ })
128
142
identity .Status .Ready = false
129
143
return reconcile.Result {}, errors .New ("secret being used by another Cluster/VSphereIdentity" )
130
144
}
@@ -145,10 +159,22 @@ func (r clusterIdentityReconciler) Reconcile(ctx context.Context, req reconcile.
145
159
err = r .Client .Update (ctx , secret )
146
160
if err != nil {
147
161
conditions .MarkFalse (identity , infrav1 .CredentialsAvailableCondidtion , infrav1 .SecretOwnerReferenceFailedReason , clusterv1 .ConditionSeverityWarning , err .Error ())
162
+ v1beta2conditions .Set (identity , metav1.Condition {
163
+ Type : infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
164
+ Status : metav1 .ConditionFalse ,
165
+ Reason : infrav1 .VSphereClusterIdentityCredentialsSecretOwnerReferenceFailedV1Beta2Reason ,
166
+ Message : err .Error (),
167
+ })
148
168
return reconcile.Result {}, err
149
169
}
150
170
151
171
conditions .MarkTrue (identity , infrav1 .CredentialsAvailableCondidtion )
172
+ v1beta2conditions .Set (identity , metav1.Condition {
173
+ Type : infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
174
+ Status : metav1 .ConditionTrue ,
175
+ Reason : infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Reason ,
176
+ })
177
+
152
178
identity .Status .Ready = true
153
179
return reconcile.Result {}, nil
154
180
}
@@ -160,6 +186,13 @@ func (r clusterIdentityReconciler) reconcileDelete(ctx context.Context, identity
160
186
Namespace : r .ControllerManagerCtx .Namespace ,
161
187
Name : identity .Spec .SecretName ,
162
188
}
189
+
190
+ v1beta2conditions .Set (identity , metav1.Condition {
191
+ Type : infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
192
+ Status : metav1 .ConditionFalse ,
193
+ Reason : infrav1 .VSphereClusterIdentityCredentialsDeletingV1Beta2Reason ,
194
+ })
195
+
163
196
err := r .Client .Get (ctx , secretKey , secret )
164
197
if err != nil {
165
198
if apierrors .IsNotFound (err ) {
0 commit comments