@@ -10,25 +10,8 @@ import (
10
10
ngfAPI "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1"
11
11
)
12
12
13
+ // Conditions and Reasons for Route resources.
13
14
const (
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
-
32
15
// RouteReasonBackendRefUnsupportedValue is used with the "ResolvedRefs" condition when one of the
33
16
// Route rules has a backendRef with an unsupported value.
34
17
RouteReasonBackendRefUnsupportedValue v1.RouteConditionReason = "UnsupportedValue"
@@ -61,6 +44,48 @@ const (
61
44
// invalid. Used with ResolvedRefs (false).
62
45
RouteReasonInvalidFilter v1.RouteConditionReason = "InvalidFilter"
63
46
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
+
64
89
// GatewayReasonUnsupportedValue is used with GatewayConditionAccepted (false) when a value of a field in a Gateway
65
90
// is invalid or not supported.
66
91
GatewayReasonUnsupportedValue v1.GatewayConditionReason = "UnsupportedValue"
@@ -70,12 +95,6 @@ const (
70
95
GatewayMessageFailedNginxReload = "The Gateway is not programmed due to a failure to " +
71
96
"reload nginx with the configuration"
72
97
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
-
79
98
// GatewayClassResolvedRefs condition indicates whether the controller was able to resolve the
80
99
// parametersRef on the GatewayClass.
81
100
GatewayClassResolvedRefs v1.GatewayClassConditionType = "ResolvedRefs"
@@ -90,7 +109,10 @@ const (
90
109
// GatewayClassReasonParamsRefInvalid is used with the "GatewayClassResolvedRefs" condition when the
91
110
// parametersRef resource is invalid.
92
111
GatewayClassReasonParamsRefInvalid v1.GatewayClassConditionReason = "ParametersRefInvalid"
112
+ )
93
113
114
+ // Conditions and Reasons for Policy resources.
115
+ const (
94
116
// PolicyReasonNginxProxyConfigNotSet is used with the "PolicyAccepted" condition when the
95
117
// NginxProxy resource is missing or invalid.
96
118
PolicyReasonNginxProxyConfigNotSet v1alpha2.PolicyConditionReason = "NginxProxyConfigNotSet"
@@ -107,6 +129,18 @@ const (
107
129
// has an overlapping hostname:port/path combination with another Route.
108
130
PolicyReasonTargetConflict v1alpha2.PolicyConditionReason = "TargetConflict"
109
131
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
+ // PolicySourceInvalid is used with the "PolicySourceInvalid" condition when a
137
+ // source of a WAFPolicy is invalid or incomplete.
138
+ PolicySourceInvalid v1alpha2.PolicyConditionReason = "SourceInvalid"
139
+
140
+ // PolicyFetchError is used with the "PolicyFetchError" condition when a
141
+ // WAFPolicy or LogProfileBundle cannot be fetched from the specified file location.
142
+ PolicyFetchError v1alpha2.PolicyConditionReason = "FetchError"
143
+
110
144
// ClientSettingsPolicyAffected is used with the "PolicyAffected" condition when a
111
145
// ClientSettingsPolicy is applied to a Gateway, HTTPRoute, or GRPCRoute.
112
146
ClientSettingsPolicyAffected v1alpha2.PolicyConditionType = "ClientSettingsPolicyAffected"
@@ -115,24 +149,9 @@ const (
115
149
// ObservabilityPolicy is applied to a HTTPRoute, or GRPCRoute.
116
150
ObservabilityPolicyAffected v1alpha2.PolicyConditionType = "ObservabilityPolicyAffected"
117
151
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"
152
+ // WAFPolicyAffected is used with the "PolicyAffected" condition when an
153
+ // WAFPolicyAffected is applied to a Gateway, HTTPRoute, or GRPCRoute.
154
+ WAFPolicyAffected v1alpha2.PolicyConditionType = "WAFPolicyAffected"
136
155
)
137
156
138
157
// Condition defines a condition to be reported in the status of resources.
@@ -998,3 +1017,34 @@ func NewClientSettingsPolicyAffected() Condition {
998
1017
Message : "ClientSettingsPolicy is applied to the resource" ,
999
1018
}
1000
1019
}
1020
+
1021
+ // NewWAFPolicyAffected returns a Condition that indicates that a WAFPolicy
1022
+ // is applied to the resource.
1023
+ func NewWAFPolicyAffected () Condition {
1024
+ return Condition {
1025
+ Type : string (WAFPolicyAffected ),
1026
+ Status : metav1 .ConditionTrue ,
1027
+ Reason : string (PolicyAffectedReason ),
1028
+ Message : "WAFPolicy is applied to the resource" ,
1029
+ }
1030
+ }
1031
+
1032
+ // NewPolicySourceInvalid returns a Condition that indicates that the WAF policy source is invalid or incomplete.
1033
+ func NewPolicySourceInvalid () Condition {
1034
+ return Condition {
1035
+ Type : string (PolicySourceInvalid ),
1036
+ Status : metav1 .ConditionFalse ,
1037
+ Reason : string (PolicySourceInvalid ),
1038
+ Message : "The policy source is invalid or incomplete." ,
1039
+ }
1040
+ }
1041
+
1042
+ // NewPolicyFetchError returns a Condition that indicates that there was an error fetching the WAF policy bundle.
1043
+ func NewPolicyFetchError (msg string ) Condition {
1044
+ return Condition {
1045
+ Type : string (PolicyFetchError ),
1046
+ Status : metav1 .ConditionFalse ,
1047
+ Reason : string (PolicyFetchError ),
1048
+ Message : "Failed to fetch the policy bundle due to: " + msg ,
1049
+ }
1050
+ }
0 commit comments