@@ -107,6 +107,18 @@ const (
107107 // has an overlapping hostname:port/path combination with another Route.
108108 PolicyReasonTargetConflict v1alpha2.PolicyConditionReason = "TargetConflict"
109109
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+
110122 // GatewayResolvedRefs condition indicates whether the controller was able to resolve the
111123 // parametersRef on the Gateway.
112124 GatewayResolvedRefs v1.GatewayConditionType = "ResolvedRefs"
@@ -185,6 +197,19 @@ func ConvertConditions(
185197 return apiConds
186198}
187199
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+
188213// NewDefaultGatewayClassConditions returns Conditions that indicate that the GatewayClass is accepted and that the
189214// Gateway API CRD versions are supported.
190215func NewDefaultGatewayClassConditions () []Condition {
@@ -940,3 +965,25 @@ func NewSnippetsFilterAccepted() Condition {
940965 Message : "SnippetsFilter is accepted" ,
941966 }
942967}
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