@@ -10,25 +10,8 @@ import (
1010 ngfAPI "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1"
1111)
1212
13+ // Conditions and Reasons for Route resources.
1314const (
14- // GatewayClassReasonGatewayClassConflict indicates there are multiple GatewayClass resources
15- // that reference this controller, and we ignored the resource in question and picked the
16- // GatewayClass that is referenced in the command-line argument.
17- // This reason is used with GatewayClassConditionAccepted (false).
18- GatewayClassReasonGatewayClassConflict v1.GatewayClassConditionReason = "GatewayClassConflict"
19-
20- // GatewayClassMessageGatewayClassConflict is a message that describes GatewayClassReasonGatewayClassConflict.
21- GatewayClassMessageGatewayClassConflict = "The resource is ignored due to a conflicting GatewayClass resource"
22-
23- // ListenerReasonUnsupportedValue is used with the "Accepted" condition when a value of a field in a Listener
24- // is invalid or not supported.
25- ListenerReasonUnsupportedValue v1.ListenerConditionReason = "UnsupportedValue"
26-
27- // ListenerMessageFailedNginxReload is a message used with ListenerConditionProgrammed (false)
28- // when nginx fails to reload.
29- ListenerMessageFailedNginxReload = "The Listener is not programmed due to a failure to " +
30- "reload nginx with the configuration"
31-
3215 // RouteReasonBackendRefUnsupportedValue is used with the "ResolvedRefs" condition when one of the
3316 // Route rules has a backendRef with an unsupported value.
3417 RouteReasonBackendRefUnsupportedValue v1.RouteConditionReason = "UnsupportedValue"
@@ -61,6 +44,48 @@ const (
6144 // invalid. Used with ResolvedRefs (false).
6245 RouteReasonInvalidFilter v1.RouteConditionReason = "InvalidFilter"
6346
47+ // RouteMessageFailedNginxReload is a message used with RouteReasonGatewayNotProgrammed
48+ // when nginx fails to reload.
49+ RouteMessageFailedNginxReload = GatewayMessageFailedNginxReload + ". NGINX may still be configured " +
50+ "for this Route. However, future updates to this resource will not be configured until the Gateway " +
51+ "is programmed again"
52+ )
53+
54+ // Conditions and Reasons for GatewayClass, Gateway and Listener resources.
55+ const (
56+ // GatewayClassReasonGatewayClassConflict indicates there are multiple GatewayClass resources
57+ // that reference this controller, and we ignored the resource in question and picked the
58+ // GatewayClass that is referenced in the command-line argument.
59+ // This reason is used with GatewayClassConditionAccepted (false).
60+ GatewayClassReasonGatewayClassConflict v1.GatewayClassConditionReason = "GatewayClassConflict"
61+
62+ // GatewayClassMessageGatewayClassConflict is a message that describes GatewayClassReasonGatewayClassConflict.
63+ GatewayClassMessageGatewayClassConflict = "The resource is ignored due to a conflicting GatewayClass resource"
64+
65+ // ListenerReasonUnsupportedValue is used with the "Accepted" condition when a value of a field in a Listener
66+ // is invalid or not supported.
67+ ListenerReasonUnsupportedValue v1.ListenerConditionReason = "UnsupportedValue"
68+
69+ // ListenerMessageFailedNginxReload is a message used with ListenerConditionProgrammed (false)
70+ // when nginx fails to reload.
71+ ListenerMessageFailedNginxReload = "The Listener is not programmed due to a failure to " +
72+ "reload nginx with the configuration"
73+
74+ // GatewayResolvedRefs condition indicates whether the controller was able to resolve the
75+ // parametersRef on the Gateway.
76+ GatewayResolvedRefs v1.GatewayConditionType = "ResolvedRefs"
77+
78+ // GatewayReasonResolvedRefs is used with the "GatewayResolvedRefs" condition when the condition is true.
79+ GatewayReasonResolvedRefs v1.GatewayConditionReason = "ResolvedRefs"
80+
81+ // GatewayReasonParamsRefNotFound is used with the "GatewayResolvedRefs" condition when the
82+ // parametersRef resource does not exist.
83+ GatewayReasonParamsRefNotFound v1.GatewayConditionReason = "ParametersRefNotFound"
84+
85+ // GatewayReasonParamsRefInvalid is used with the "GatewayResolvedRefs" condition when the
86+ // parametersRef resource is invalid.
87+ GatewayReasonParamsRefInvalid v1.GatewayConditionReason = "ParametersRefInvalid"
88+
6489 // GatewayReasonUnsupportedValue is used with GatewayConditionAccepted (false) when a value of a field in a Gateway
6590 // is invalid or not supported.
6691 GatewayReasonUnsupportedValue v1.GatewayConditionReason = "UnsupportedValue"
@@ -70,12 +95,6 @@ const (
7095 GatewayMessageFailedNginxReload = "The Gateway is not programmed due to a failure to " +
7196 "reload nginx with the configuration"
7297
73- // RouteMessageFailedNginxReload is a message used with RouteReasonGatewayNotProgrammed
74- // when nginx fails to reload.
75- RouteMessageFailedNginxReload = GatewayMessageFailedNginxReload + ". NGINX may still be configured " +
76- "for this Route. However, future updates to this resource will not be configured until the Gateway " +
77- "is programmed again"
78-
7998 // GatewayClassResolvedRefs condition indicates whether the controller was able to resolve the
8099 // parametersRef on the GatewayClass.
81100 GatewayClassResolvedRefs v1.GatewayClassConditionType = "ResolvedRefs"
@@ -90,7 +109,10 @@ const (
90109 // GatewayClassReasonParamsRefInvalid is used with the "GatewayClassResolvedRefs" condition when the
91110 // parametersRef resource is invalid.
92111 GatewayClassReasonParamsRefInvalid v1.GatewayClassConditionReason = "ParametersRefInvalid"
112+ )
93113
114+ // Conditions and Reasons for Policy resources.
115+ const (
94116 // PolicyReasonNginxProxyConfigNotSet is used with the "PolicyAccepted" condition when the
95117 // NginxProxy resource is missing or invalid.
96118 PolicyReasonNginxProxyConfigNotSet v1alpha2.PolicyConditionReason = "NginxProxyConfigNotSet"
@@ -107,6 +129,22 @@ const (
107129 // has an overlapping hostname:port/path combination with another Route.
108130 PolicyReasonTargetConflict v1alpha2.PolicyConditionReason = "TargetConflict"
109131
132+ // PolicyAffectedReason is used with the "PolicyAffected" condition when a
133+ // ObservabilityPolicy or ClientSettingsPolicy is applied to Gateways or Routes.
134+ PolicyAffectedReason v1alpha2.PolicyConditionReason = "PolicyAffected"
135+
136+ // WAFPolicyFetchError is used with the "WAFPolicyFetchError" condition when a
137+ // WAFPolicy or LogProfileBundle cannot be fetched from the specified file location.
138+ WAFPolicyFetchError v1alpha2.PolicyConditionReason = "FetchError"
139+
140+ // WAFPolicyMessageSourceInvalid is a message used with the "PolicyInvalid" condition
141+ // when the WAF policy source is invalid or incomplete.
142+ WAFPolicyMessageSourceInvalid = "The WAF policy source is invalid or incomplete."
143+
144+ // WAFSecurityLogMessageSourceInvalid is a message used with the "PolicyInvalid" condition
145+ // when the WAFSecurityLog source is invalid or incomplete.
146+ WAFSecurityLogMessageSourceInvalid = "The WAFSecurityLog source is invalid or incomplete."
147+
110148 // ClientSettingsPolicyAffected is used with the "PolicyAffected" condition when a
111149 // ClientSettingsPolicy is applied to a Gateway, HTTPRoute, or GRPCRoute.
112150 ClientSettingsPolicyAffected v1alpha2.PolicyConditionType = "ClientSettingsPolicyAffected"
@@ -115,24 +153,9 @@ const (
115153 // ObservabilityPolicy is applied to a HTTPRoute, or GRPCRoute.
116154 ObservabilityPolicyAffected v1alpha2.PolicyConditionType = "ObservabilityPolicyAffected"
117155
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-
122- // GatewayResolvedRefs condition indicates whether the controller was able to resolve the
123- // parametersRef on the Gateway.
124- GatewayResolvedRefs v1.GatewayConditionType = "ResolvedRefs"
125-
126- // GatewayReasonResolvedRefs is used with the "GatewayResolvedRefs" condition when the condition is true.
127- GatewayReasonResolvedRefs v1.GatewayConditionReason = "ResolvedRefs"
128-
129- // GatewayReasonParamsRefNotFound is used with the "GatewayResolvedRefs" condition when the
130- // parametersRef resource does not exist.
131- GatewayReasonParamsRefNotFound v1.GatewayConditionReason = "ParametersRefNotFound"
132-
133- // GatewayReasonParamsRefInvalid is used with the "GatewayResolvedRefs" condition when the
134- // parametersRef resource is invalid.
135- GatewayReasonParamsRefInvalid v1.GatewayConditionReason = "ParametersRefInvalid"
156+ // WAFPolicyAffected is used with the "PolicyAffected" condition when an
157+ // WAFPolicyAffected is applied to a Gateway, HTTPRoute, or GRPCRoute.
158+ WAFPolicyAffected v1alpha2.PolicyConditionType = "WAFPolicyAffected"
136159)
137160
138161// Condition defines a condition to be reported in the status of resources.
@@ -998,3 +1021,24 @@ func NewClientSettingsPolicyAffected() Condition {
9981021 Message : "ClientSettingsPolicy is applied to the resource" ,
9991022 }
10001023}
1024+
1025+ // NewWAFPolicyAffected returns a Condition that indicates that a WAFPolicy
1026+ // is applied to the resource.
1027+ func NewWAFPolicyAffected () Condition {
1028+ return Condition {
1029+ Type : string (WAFPolicyAffected ),
1030+ Status : metav1 .ConditionTrue ,
1031+ Reason : string (PolicyAffectedReason ),
1032+ Message : "WAFPolicy is applied to the resource" ,
1033+ }
1034+ }
1035+
1036+ // NewWAFPolicyFetchError returns a Condition that indicates that there was an error fetching the WAF policy bundle.
1037+ func NewWAFPolicyFetchError (msg string ) Condition {
1038+ return Condition {
1039+ Type : string (WAFPolicyFetchError ),
1040+ Status : metav1 .ConditionFalse ,
1041+ Reason : string (WAFPolicyFetchError ),
1042+ Message : "Failed to fetch the policy bundle due to: " + msg ,
1043+ }
1044+ }
0 commit comments