@@ -2,14 +2,11 @@ package controllers
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"fmt"
7
6
"slices"
8
7
"sync"
9
8
10
9
"github.com/go-logr/logr"
11
- authorinov1beta1 "github.com/kuadrant/authorino-operator/api/v1beta1"
12
- limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"
13
10
"github.com/kuadrant/policy-machinery/controller"
14
11
"github.com/kuadrant/policy-machinery/machinery"
15
12
corev1 "k8s.io/api/core/v1"
@@ -128,43 +125,33 @@ func (r *KuadrantStatusUpdater) readyCondition(topology *machinery.Topology, log
128
125
return cond
129
126
}
130
127
131
- limitadorObj , err := GetLimitadorFromTopology (topology )
132
- if err != nil && ! errors .Is (err , ErrMissingLimitador ) {
133
- logger .V (1 ).Error (err , "failed getting Limitador resource from topology" , "status" , "error" )
134
- }
135
-
136
- if limitadorObj != nil {
137
- reason := checkLimitadorReady (limitadorObj )
138
- if reason != nil {
139
- cond .Status = metav1 .ConditionFalse
140
- cond .Reason = "limitadornotready"
141
- cond .Message = * reason
142
- return cond
143
- }
128
+ if reason := checkLimitadorReady (topology , logger ); reason != nil {
129
+ cond .Status = metav1 .ConditionFalse
130
+ cond .Reason = "LimitadorNotReady"
131
+ cond .Message = * reason
132
+ return cond
144
133
}
145
134
146
- authorinoObj , err := GetAuthorinoFromTopology (topology )
147
- if err != nil && ! errors .Is (err , ErrMissingAuthorino ) {
148
- logger .V (1 ).Error (err , "failed getting Authorino resource from topology" , "status" , "error" )
135
+ if reason := checkAuthorinoAvailable (topology , logger ); reason != nil {
136
+ cond .Status = metav1 .ConditionFalse
137
+ cond .Reason = "AuthorinoNotReady"
138
+ cond .Message = * reason
139
+ return cond
149
140
}
150
141
151
- if authorinoObj != nil {
152
- reason := checkAuthorinoAvailable (authorinoObj )
153
- if reason != nil {
154
- cond .Status = metav1 .ConditionFalse
155
- cond .Reason = "AuthorinoNotReady"
156
- cond .Message = * reason
157
- return cond
158
- }
159
- }
160
142
return cond
161
143
}
162
144
163
- func checkLimitadorReady (limitadorObj * limitadorv1alpha1.Limitador ) * string {
145
+ func checkLimitadorReady (topology * machinery.Topology , logger logr.Logger ) * string {
146
+ limitadorObj , err := GetLimitadorFromTopology (topology )
147
+ if err != nil {
148
+ logger .V (1 ).Error (err , "failed getting Limitador resource from topology" , "status" , "error" )
149
+ return ptr .To (err .Error ())
150
+ }
151
+
164
152
statusConditionReady := meta .FindStatusCondition (limitadorObj .Status .Conditions , "Ready" )
165
153
if statusConditionReady == nil {
166
- reason := "Ready condition not found"
167
- return & reason
154
+ return ptr .To ("Ready condition not found" )
168
155
}
169
156
if statusConditionReady .Status != metav1 .ConditionTrue {
170
157
return & statusConditionReady .Message
@@ -173,11 +160,16 @@ func checkLimitadorReady(limitadorObj *limitadorv1alpha1.Limitador) *string {
173
160
return nil
174
161
}
175
162
176
- func checkAuthorinoAvailable (authorinoObj * authorinov1beta1.Authorino ) * string {
163
+ func checkAuthorinoAvailable (topology * machinery.Topology , logger logr.Logger ) * string {
164
+ authorinoObj , err := GetAuthorinoFromTopology (topology )
165
+ if err != nil {
166
+ logger .V (1 ).Error (err , "failed getting Authorino resource from topology" , "status" , "error" )
167
+ return ptr .To (err .Error ())
168
+ }
169
+
177
170
readyCondition := authorino .FindAuthorinoStatusCondition (authorinoObj .Status .Conditions , "Ready" )
178
171
if readyCondition == nil {
179
- tmp := "Ready condition not found"
180
- return & tmp
172
+ return ptr .To ("Ready condition not found" )
181
173
}
182
174
183
175
if readyCondition .Status != corev1 .ConditionTrue {
0 commit comments