@@ -107,6 +107,18 @@ const (
107
107
// has an overlapping hostname:port/path combination with another Route.
108
108
PolicyReasonTargetConflict v1alpha2.PolicyConditionReason = "TargetConflict"
109
109
110
+ // ClientSettingsPolicyAffected is used with the "PolicyAffected" condition when a
111
+ // ClientSettingsPolicy is applied to a Gateway, HTTPRoute, or GRPCRoute.
112
+ ClientSettingsPolicyAffected v1alpha2.PolicyConditionType = "ClientSettingsPolicyAffected"
113
+
114
+ // ObservabilityPolicyAffected is used with the "PolicyAffected" condition when an
115
+ // ObservabilityPolicy is applied to a HTTPRoute, or GRPCRoute.
116
+ ObservabilityPolicyAffected v1alpha2.PolicyConditionType = "ObservabilityPolicyAffected"
117
+
118
+ // PolicyAffectedReason is used with the "PolicyAffected" condition when a
119
+ // ObservabilityPolicy or ClientSettingsPolicy is applied to Gateways or Routes.
120
+ PolicyAffectedReason v1alpha2.PolicyConditionReason = "PolicyAffected"
121
+
110
122
// GatewayResolvedRefs condition indicates whether the controller was able to resolve the
111
123
// parametersRef on the Gateway.
112
124
GatewayResolvedRefs v1.GatewayConditionType = "ResolvedRefs"
@@ -185,6 +197,33 @@ func ConvertConditions(
185
197
return apiConds
186
198
}
187
199
200
+ // HasMatchingCondition checks if the given condition matches any of the existing conditions.
201
+ func HasMatchingCondition (existingConditions []Condition , cond Condition ) bool {
202
+ condMap := make (map [Condition ]struct {}, len (existingConditions ))
203
+ for _ , cond := range existingConditions {
204
+ key := Condition {
205
+ Type : cond .Type ,
206
+ Status : cond .Status ,
207
+ Reason : cond .Reason ,
208
+ Message : cond .Message ,
209
+ }
210
+ condMap [key ] = struct {}{}
211
+ }
212
+
213
+ key := Condition {
214
+ Type : cond .Type ,
215
+ Status : cond .Status ,
216
+ Reason : cond .Reason ,
217
+ Message : cond .Message ,
218
+ }
219
+
220
+ if _ , exists := condMap [key ]; exists {
221
+ return true
222
+ }
223
+
224
+ return false
225
+ }
226
+
188
227
// NewDefaultGatewayClassConditions returns Conditions that indicate that the GatewayClass is accepted and that the
189
228
// Gateway API CRD versions are supported.
190
229
func NewDefaultGatewayClassConditions () []Condition {
@@ -940,3 +979,25 @@ func NewSnippetsFilterAccepted() Condition {
940
979
Message : "SnippetsFilter is accepted" ,
941
980
}
942
981
}
982
+
983
+ // NewObservabilityPolicyAffected returns a Condition that indicates that an ObservabilityPolicy
984
+ // is applied to the resource.
985
+ func NewObservabilityPolicyAffected () Condition {
986
+ return Condition {
987
+ Type : string (ObservabilityPolicyAffected ),
988
+ Status : metav1 .ConditionTrue ,
989
+ Reason : string (PolicyAffectedReason ),
990
+ Message : "ObservabilityPolicy is applied to the resource" ,
991
+ }
992
+ }
993
+
994
+ // NewClientSettingsPolicyAffected returns a Condition that indicates that a ClientSettingsPolicy
995
+ // is applied to the resource.
996
+ func NewClientSettingsPolicyAffected () Condition {
997
+ return Condition {
998
+ Type : string (ClientSettingsPolicyAffected ),
999
+ Status : metav1 .ConditionTrue ,
1000
+ Reason : string (PolicyAffectedReason ),
1001
+ Message : "ClientSettingsPolicy is applied to the resource" ,
1002
+ }
1003
+ }
0 commit comments