@@ -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,19 @@ 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
+ for _ , existing := range existingConditions {
203
+ if existing .Type == cond .Type &&
204
+ existing .Status == cond .Status &&
205
+ existing .Reason == cond .Reason &&
206
+ existing .Message == cond .Message {
207
+ return true
208
+ }
209
+ }
210
+ return false
211
+ }
212
+
188
213
// NewDefaultGatewayClassConditions returns Conditions that indicate that the GatewayClass is accepted and that the
189
214
// Gateway API CRD versions are supported.
190
215
func NewDefaultGatewayClassConditions () []Condition {
@@ -940,3 +965,25 @@ func NewSnippetsFilterAccepted() Condition {
940
965
Message : "SnippetsFilter is accepted" ,
941
966
}
942
967
}
968
+
969
+ // NewObservabilityPolicyAffected returns a Condition that indicates that an ObservabilityPolicy
970
+ // is applied to the resource.
971
+ func NewObservabilityPolicyAffected () Condition {
972
+ return Condition {
973
+ Type : string (ObservabilityPolicyAffected ),
974
+ Status : metav1 .ConditionTrue ,
975
+ Reason : string (PolicyAffectedReason ),
976
+ Message : "ObservabilityPolicy is applied to the resource" ,
977
+ }
978
+ }
979
+
980
+ // NewClientSettingsPolicyAffected returns a Condition that indicates that a ClientSettingsPolicy
981
+ // is applied to the resource.
982
+ func NewClientSettingsPolicyAffected () Condition {
983
+ return Condition {
984
+ Type : string (ClientSettingsPolicyAffected ),
985
+ Status : metav1 .ConditionTrue ,
986
+ Reason : string (PolicyAffectedReason ),
987
+ Message : "ClientSettingsPolicy is applied to the resource" ,
988
+ }
989
+ }
0 commit comments