@@ -30,6 +30,7 @@ import (
3030 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3131 clusterutilv1 "sigs.k8s.io/cluster-api/util"
3232 "sigs.k8s.io/cluster-api/util/conditions"
33+ v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
3334 "sigs.k8s.io/cluster-api/util/finalizers"
3435 "sigs.k8s.io/cluster-api/util/patch"
3536 "sigs.k8s.io/cluster-api/util/paused"
@@ -102,6 +103,7 @@ func (r clusterIdentityReconciler) Reconcile(ctx context.Context, req reconcile.
102103
103104 if err := patchHelper .Patch (ctx , identity , patch.WithOwnedV1Beta2Conditions {Conditions : []string {
104105 clusterv1 .PausedV1Beta2Condition ,
106+ infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
105107 }}); err != nil {
106108 reterr = kerrors .NewAggregate ([]error {reterr , err })
107109 }
@@ -119,12 +121,24 @@ func (r clusterIdentityReconciler) Reconcile(ctx context.Context, req reconcile.
119121 }
120122 if err := r .Client .Get (ctx , secretKey , secret ); err != nil {
121123 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+ })
122130 return reconcile.Result {}, errors .Wrapf (err , "failed to get Secret %s" , klog .KRef (secretKey .Namespace , secretKey .Name ))
123131 }
124132
125133 // If this secret is owned by a different VSphereClusterIdentity or a VSphereCluster, mark the identity as not ready and return an error.
126134 if ! clusterutilv1 .IsOwnedByObject (secret , identity ) && pkgidentity .IsOwnedByIdentityOrCluster (secret .GetOwnerReferences ()) {
127135 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+ })
128142 identity .Status .Ready = false
129143 return reconcile.Result {}, errors .New ("secret being used by another Cluster/VSphereIdentity" )
130144 }
@@ -145,10 +159,22 @@ func (r clusterIdentityReconciler) Reconcile(ctx context.Context, req reconcile.
145159 err = r .Client .Update (ctx , secret )
146160 if err != nil {
147161 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+ })
148168 return reconcile.Result {}, err
149169 }
150170
151171 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+
152178 identity .Status .Ready = true
153179 return reconcile.Result {}, nil
154180}
@@ -160,6 +186,13 @@ func (r clusterIdentityReconciler) reconcileDelete(ctx context.Context, identity
160186 Namespace : r .ControllerManagerCtx .Namespace ,
161187 Name : identity .Spec .SecretName ,
162188 }
189+
190+ v1beta2conditions .Set (identity , metav1.Condition {
191+ Type : infrav1 .VSphereClusterIdentityCredentialsAvailableV1Beta2Condition ,
192+ Status : metav1 .ConditionFalse ,
193+ Reason : infrav1 .VSphereClusterIdentityCredentialsDeletingV1Beta2Reason ,
194+ })
195+
163196 err := r .Client .Get (ctx , secretKey , secret )
164197 if err != nil {
165198 if apierrors .IsNotFound (err ) {
0 commit comments