Skip to content

Commit 9d2bf35

Browse files
authored
Alignment for Conditions messages format (#4253)
Alignment for Conditions messages format Decided to use next format: - Start with The if can be - Second word make capitalized as it is used everywhere in description for all: Listener, Gateway, GatewayClass, InferencePool and even Route - Replace split to combined, if there is both used, like inference pool => InferencePool. - Example: "The Gateway is invalid"
1 parent ec97d7a commit 9d2bf35

22 files changed

+261
-197
lines changed

internal/controller/nginx/config/policies/validator_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ var _ = Describe("Policy CompositeValidator", func() {
4949
policies.ManagerConfig{
5050
Validator: &policiesfakes.FakeValidator{
5151
ValidateStub: func(_ policies.Policy) []conditions.Condition {
52-
return []conditions.Condition{conditions.NewPolicyInvalid("apple error")}
52+
return []conditions.Condition{conditions.NewPolicyInvalid("Apple error")}
5353
},
5454
ValidateGlobalSettingsStub: func(_ policies.Policy, _ *policies.GlobalSettings) []conditions.Condition {
55-
return []conditions.Condition{conditions.NewPolicyInvalid("apple global settings error")}
55+
return []conditions.Condition{conditions.NewPolicyInvalid("Apple global settings error")}
5656
},
5757
ConflictsStub: func(_ policies.Policy, _ policies.Policy) bool { return true },
5858
},
@@ -61,10 +61,10 @@ var _ = Describe("Policy CompositeValidator", func() {
6161
policies.ManagerConfig{
6262
Validator: &policiesfakes.FakeValidator{
6363
ValidateStub: func(_ policies.Policy) []conditions.Condition {
64-
return []conditions.Condition{conditions.NewPolicyInvalid("orange error")}
64+
return []conditions.Condition{conditions.NewPolicyInvalid("Orange error")}
6565
},
6666
ValidateGlobalSettingsStub: func(_ policies.Policy, _ *policies.GlobalSettings) []conditions.Condition {
67-
return []conditions.Condition{conditions.NewPolicyInvalid("orange global settings error")}
67+
return []conditions.Condition{conditions.NewPolicyInvalid("Orange global settings error")}
6868
},
6969
ConflictsStub: func(_ policies.Policy, _ policies.Policy) bool { return false },
7070
},
@@ -83,19 +83,18 @@ var _ = Describe("Policy CompositeValidator", func() {
8383

8484
conds := mgr.Validate(applePolicy)
8585
Expect(conds).To(HaveLen(1))
86-
Expect(conds[0].Message).To(Equal("apple error"))
86+
Expect(conds[0].Message).To(Equal("Apple error"))
8787

8888
conds = mgr.ValidateGlobalSettings(applePolicy, globalSettings)
8989
Expect(conds).To(HaveLen(1))
90-
Expect(conds[0].Message).To(Equal("apple global settings error"))
91-
90+
Expect(conds[0].Message).To(Equal("Apple global settings error"))
9291
conds = mgr.Validate(orangePolicy)
9392
Expect(conds).To(HaveLen(1))
94-
Expect(conds[0].Message).To(Equal("orange error"))
93+
Expect(conds[0].Message).To(Equal("Orange error"))
9594

9695
conds = mgr.ValidateGlobalSettings(orangePolicy, globalSettings)
9796
Expect(conds).To(HaveLen(1))
98-
Expect(conds[0].Message).To(Equal("orange global settings error"))
97+
Expect(conds[0].Message).To(Equal("Orange global settings error"))
9998
})
10099
It("Returns whether the policies conflict", func() {
101100
Expect(mgr.Conflicts(applePolicy, applePolicy)).To(BeTrue())

internal/controller/state/change_processor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ var _ = Describe("ChangeProcessor", func() {
12761276
expGraph.GatewayClass = nil
12771277

12781278
gw := expGraph.Gateways[types.NamespacedName{Namespace: "test", Name: "gateway-1"}]
1279-
gw.Conditions = conditions.NewGatewayInvalid("GatewayClass doesn't exist")
1279+
gw.Conditions = conditions.NewGatewayInvalid("The GatewayClass doesn't exist")
12801280
gw.Valid = false
12811281
gw.Listeners = nil
12821282

@@ -2253,7 +2253,7 @@ var _ = Describe("ChangeProcessor", func() {
22532253
},
22542254
},
22552255
},
2256-
Conditions: conditions.NewGatewayInvalid("GatewayClass doesn't exist"),
2256+
Conditions: conditions.NewGatewayInvalid("The GatewayClass doesn't exist"),
22572257
DeploymentName: types.NamespacedName{
22582258
Namespace: "test",
22592259
Name: "gateway-2-test-class",

internal/controller/state/conditions/conditions.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ func NewDefaultGatewayClassConditions() []Condition {
239239
Type: string(v1.GatewayClassConditionStatusAccepted),
240240
Status: metav1.ConditionTrue,
241241
Reason: string(v1.GatewayClassReasonAccepted),
242-
Message: "GatewayClass is accepted",
242+
Message: "The GatewayClass is accepted",
243243
},
244244
{
245245
Type: string(v1.GatewayClassConditionStatusSupportedVersion),
246246
Status: metav1.ConditionTrue,
247247
Reason: string(v1.GatewayClassReasonSupportedVersion),
248-
Message: "Gateway API CRD versions are supported",
248+
Message: "The Gateway API CRD versions are supported",
249249
},
250250
}
251251
}
@@ -260,7 +260,7 @@ func NewGatewayClassSupportedVersionBestEffort(recommendedVersion string) []Cond
260260
Status: metav1.ConditionFalse,
261261
Reason: string(v1.GatewayClassReasonUnsupportedVersion),
262262
Message: fmt.Sprintf(
263-
"Gateway API CRD versions are not recommended. Recommended version is %s",
263+
"The Gateway API CRD versions are not recommended. Recommended version is %s",
264264
recommendedVersion,
265265
),
266266
},
@@ -276,7 +276,7 @@ func NewGatewayClassUnsupportedVersion(recommendedVersion string) []Condition {
276276
Status: metav1.ConditionFalse,
277277
Reason: string(v1.GatewayClassReasonUnsupportedVersion),
278278
Message: fmt.Sprintf(
279-
"Gateway API CRD versions are not supported. Please install version %s",
279+
"The Gateway API CRD versions are not supported. Please install version %s",
280280
recommendedVersion,
281281
),
282282
},
@@ -285,7 +285,7 @@ func NewGatewayClassUnsupportedVersion(recommendedVersion string) []Condition {
285285
Status: metav1.ConditionFalse,
286286
Reason: string(v1.GatewayClassReasonUnsupportedVersion),
287287
Message: fmt.Sprintf(
288-
"Gateway API CRD versions are not supported. Please install version %s",
288+
"The Gateway API CRD versions are not supported. Please install version %s",
289289
recommendedVersion,
290290
),
291291
},
@@ -318,18 +318,18 @@ func NewRouteNotAllowedByListeners() Condition {
318318
Type: string(v1.RouteConditionAccepted),
319319
Status: metav1.ConditionFalse,
320320
Reason: string(v1.RouteReasonNotAllowedByListeners),
321-
Message: "Route is not allowed by any listener",
321+
Message: "The Route is not allowed by any listener",
322322
}
323323
}
324324

325-
// NewRouteNoMatchingListenerHostname returns a Condition that indicates that the hostname of the listener
325+
// NewRouteNoMatchingListenerHostname returns a Condition that indicates that the hostname of the Listener
326326
// does not match the hostnames of the Route.
327327
func NewRouteNoMatchingListenerHostname() Condition {
328328
return Condition{
329329
Type: string(v1.RouteConditionAccepted),
330330
Status: metav1.ConditionFalse,
331331
Reason: string(v1.RouteReasonNoMatchingListenerHostname),
332-
Message: "Listener hostname does not match the Route hostnames",
332+
Message: "The Listener hostname does not match the Route hostnames",
333333
}
334334
}
335335

@@ -339,7 +339,7 @@ func NewRouteAccepted() Condition {
339339
Type: string(v1.RouteConditionAccepted),
340340
Status: metav1.ConditionTrue,
341341
Reason: string(v1.RouteReasonAccepted),
342-
Message: "The route is accepted",
342+
Message: "The Route is accepted",
343343
}
344344
}
345345

@@ -386,7 +386,7 @@ func NewRouteInvalidListener() Condition {
386386
Type: string(v1.RouteConditionAccepted),
387387
Status: metav1.ConditionFalse,
388388
Reason: string(RouteReasonInvalidListener),
389-
Message: "Listener is invalid for this parent ref",
389+
Message: "The Listener is invalid for this parent ref",
390390
}
391391
}
392392

@@ -397,7 +397,7 @@ func NewRouteHostnameConflict() Condition {
397397
Type: string(v1.RouteConditionAccepted),
398398
Status: metav1.ConditionFalse,
399399
Reason: string(RouteReasonHostnameConflict),
400-
Message: "Hostname(s) conflict with another route of the same kind on the same port",
400+
Message: "Hostname(s) conflict with another Route of the same kind on the same port",
401401
}
402402
}
403403

@@ -484,7 +484,7 @@ func NewRouteInvalidGateway() Condition {
484484
Type: string(v1.RouteConditionAccepted),
485485
Status: metav1.ConditionFalse,
486486
Reason: string(RouteReasonInvalidGateway),
487-
Message: "Gateway is invalid",
487+
Message: "The Gateway is invalid",
488488
}
489489
}
490490

@@ -495,7 +495,7 @@ func NewRouteNoMatchingParent() Condition {
495495
Type: string(v1.RouteConditionAccepted),
496496
Status: metav1.ConditionFalse,
497497
Reason: string(v1.RouteReasonNoMatchingParent),
498-
Message: "Listener is not found for this parent ref",
498+
Message: "The Listener is not found for this parent ref",
499499
}
500500
}
501501

@@ -550,7 +550,7 @@ func NewDefaultListenerConditions(existingConditions []Condition) []Condition {
550550
return defaultConds
551551
}
552552

553-
// hasConflictConditions checks if the listener has any conflict-related conditions.
553+
// hasConflictConditions checks if the Listener has any conflict-related conditions.
554554
func hasConflictConditions(conditions []Condition) bool {
555555
for _, cond := range conditions {
556556
if cond.Type == string(v1.ListenerConditionConflicted) ||
@@ -567,7 +567,7 @@ func NewListenerAccepted() Condition {
567567
Type: string(v1.ListenerConditionAccepted),
568568
Status: metav1.ConditionTrue,
569569
Reason: string(v1.ListenerReasonAccepted),
570-
Message: "Listener is accepted",
570+
Message: "The Listener is accepted",
571571
}
572572
}
573573

@@ -577,7 +577,7 @@ func NewListenerProgrammed() Condition {
577577
Type: string(v1.ListenerConditionProgrammed),
578578
Status: metav1.ConditionTrue,
579579
Reason: string(v1.ListenerReasonProgrammed),
580-
Message: "Listener is programmed",
580+
Message: "The Listener is programmed",
581581
}
582582
}
583583

@@ -750,7 +750,7 @@ func NewGatewayClassResolvedRefs() Condition {
750750
Type: string(GatewayClassResolvedRefs),
751751
Status: metav1.ConditionTrue,
752752
Reason: string(GatewayClassReasonResolvedRefs),
753-
Message: "ParametersRef resource is resolved",
753+
Message: "The ParametersRef resource is resolved",
754754
}
755755
}
756756

@@ -761,7 +761,7 @@ func NewGatewayClassRefNotFound() Condition {
761761
Type: string(GatewayClassResolvedRefs),
762762
Status: metav1.ConditionFalse,
763763
Reason: string(GatewayClassReasonParamsRefNotFound),
764-
Message: "ParametersRef resource could not be found",
764+
Message: "The ParametersRef resource could not be found",
765765
}
766766
}
767767

@@ -784,7 +784,7 @@ func NewGatewayClassInvalidParameters(msg string) Condition {
784784
Type: string(v1.GatewayClassConditionStatusAccepted),
785785
Status: metav1.ConditionTrue,
786786
Reason: string(v1.GatewayClassReasonInvalidParameters),
787-
Message: fmt.Sprintf("GatewayClass is accepted, but ParametersRef is ignored due to an error: %s", msg),
787+
Message: fmt.Sprintf("The GatewayClass is accepted, but ParametersRef is ignored due to an error: %s", msg),
788788
}
789789
}
790790

@@ -802,7 +802,7 @@ func NewGatewayAccepted() Condition {
802802
Type: string(v1.GatewayConditionAccepted),
803803
Status: metav1.ConditionTrue,
804804
Reason: string(v1.GatewayReasonAccepted),
805-
Message: "Gateway is accepted",
805+
Message: "The Gateway is accepted",
806806
}
807807
}
808808

@@ -813,14 +813,14 @@ func NewGatewayAcceptedListenersNotValid() Condition {
813813
Type: string(v1.GatewayConditionAccepted),
814814
Status: metav1.ConditionTrue,
815815
Reason: string(v1.GatewayReasonListenersNotValid),
816-
Message: "Gateway has at least one valid listener",
816+
Message: "The Gateway has at least one valid listener",
817817
}
818818
}
819819

820820
// NewGatewayNotAcceptedListenersNotValid returns Conditions that indicate the Gateway is not accepted,
821821
// because all listeners are invalid.
822822
func NewGatewayNotAcceptedListenersNotValid() []Condition {
823-
msg := "Gateway has no valid listeners"
823+
msg := "The Gateway has no valid listeners"
824824
return []Condition{
825825
{
826826
Type: string(v1.GatewayConditionAccepted),
@@ -885,7 +885,7 @@ func NewGatewayProgrammed() Condition {
885885
Type: string(v1.GatewayConditionProgrammed),
886886
Status: metav1.ConditionTrue,
887887
Reason: string(v1.GatewayReasonProgrammed),
888-
Message: "Gateway is programmed",
888+
Message: "The Gateway is programmed",
889889
}
890890
}
891891

@@ -907,7 +907,7 @@ func NewNginxGatewayValid() Condition {
907907
Type: string(ngfAPI.NginxGatewayConditionValid),
908908
Status: metav1.ConditionTrue,
909909
Reason: string(ngfAPI.NginxGatewayReasonValid),
910-
Message: "NginxGateway is valid",
910+
Message: "The NginxGateway is valid",
911911
}
912912
}
913913

@@ -928,7 +928,7 @@ func NewGatewayResolvedRefs() Condition {
928928
Type: string(GatewayResolvedRefs),
929929
Status: metav1.ConditionTrue,
930930
Reason: string(GatewayReasonResolvedRefs),
931-
Message: "ParametersRef resource is resolved",
931+
Message: "The ParametersRef resource is resolved",
932932
}
933933
}
934934

@@ -939,7 +939,7 @@ func NewGatewayRefNotFound() Condition {
939939
Type: string(GatewayResolvedRefs),
940940
Status: metav1.ConditionFalse,
941941
Reason: string(GatewayReasonParamsRefNotFound),
942-
Message: "ParametersRef resource could not be found",
942+
Message: "The ParametersRef resource could not be found",
943943
}
944944
}
945945

@@ -962,7 +962,7 @@ func NewGatewayInvalidParameters(msg string) Condition {
962962
Type: string(v1.GatewayConditionAccepted),
963963
Status: metav1.ConditionTrue,
964964
Reason: string(v1.GatewayReasonInvalidParameters),
965-
Message: fmt.Sprintf("Gateway is accepted, but ParametersRef is ignored due to an error: %s", msg),
965+
Message: fmt.Sprintf("The Gateway is accepted, but ParametersRef is ignored due to an error: %s", msg),
966966
}
967967
}
968968

@@ -973,7 +973,7 @@ func NewGatewayAcceptedUnsupportedField(msg string) Condition {
973973
Type: string(v1.GatewayConditionAccepted),
974974
Status: metav1.ConditionTrue,
975975
Reason: string(GatewayReasonUnsupportedField),
976-
Message: fmt.Sprintf("Gateway accepted but the following unsupported parameters were ignored: %s", msg),
976+
Message: fmt.Sprintf("The Gateway is accepted but the following unsupported parameters were ignored: %s", msg),
977977
}
978978
}
979979

@@ -983,7 +983,7 @@ func NewPolicyAccepted() Condition {
983983
Type: string(v1.PolicyConditionAccepted),
984984
Status: metav1.ConditionTrue,
985985
Reason: string(v1.PolicyReasonAccepted),
986-
Message: "Policy is accepted",
986+
Message: "The Policy is accepted",
987987
}
988988
}
989989

@@ -1071,7 +1071,7 @@ func NewSnippetsFilterAccepted() Condition {
10711071
Type: string(ngfAPI.SnippetsFilterConditionTypeAccepted),
10721072
Status: metav1.ConditionTrue,
10731073
Reason: string(ngfAPI.SnippetsFilterConditionReasonAccepted),
1074-
Message: "SnippetsFilter is accepted",
1074+
Message: "The SnippetsFilter is accepted",
10751075
}
10761076
}
10771077

@@ -1082,7 +1082,7 @@ func NewObservabilityPolicyAffected() Condition {
10821082
Type: string(ObservabilityPolicyAffected),
10831083
Status: metav1.ConditionTrue,
10841084
Reason: string(PolicyAffectedReason),
1085-
Message: "ObservabilityPolicy is applied to the resource",
1085+
Message: "The ObservabilityPolicy is applied to the resource",
10861086
}
10871087
}
10881088

@@ -1093,7 +1093,7 @@ func NewClientSettingsPolicyAffected() Condition {
10931093
Type: string(ClientSettingsPolicyAffected),
10941094
Status: metav1.ConditionTrue,
10951095
Reason: string(PolicyAffectedReason),
1096-
Message: "ClientSettingsPolicy is applied to the resource",
1096+
Message: "The ClientSettingsPolicy is applied to the resource",
10971097
}
10981098
}
10991099

@@ -1147,7 +1147,7 @@ func NewInferencePoolAccepted() Condition {
11471147
Type: string(inference.InferencePoolConditionAccepted),
11481148
Status: metav1.ConditionTrue,
11491149
Reason: string(inference.InferencePoolConditionAccepted),
1150-
Message: "InferencePool is accepted by the Gateway.",
1150+
Message: "The InferencePool is accepted by the Gateway.",
11511151
}
11521152
}
11531153

@@ -1158,7 +1158,7 @@ func NewInferencePoolResolvedRefs() Condition {
11581158
Type: string(inference.InferencePoolConditionResolvedRefs),
11591159
Status: metav1.ConditionTrue,
11601160
Reason: string(inference.InferencePoolConditionResolvedRefs),
1161-
Message: "Inference pool references a valid ExtensionRef.",
1161+
Message: "The InferencePool references a valid ExtensionRef.",
11621162
}
11631163
}
11641164

0 commit comments

Comments
 (0)