Skip to content

Commit 05bc535

Browse files
committed
Alignment for Conditions messages format
1 parent fc3c682 commit 05bc535

File tree

4 files changed

+91
-89
lines changed

4 files changed

+91
-89
lines changed

internal/controller/state/conditions/conditions.go

Lines changed: 32 additions & 32 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,7 +318,7 @@ 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

@@ -329,7 +329,7 @@ func NewRouteNoMatchingListenerHostname() 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

@@ -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

internal/controller/state/graph/backend_refs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ func findBackendTLSPolicyForService(
419419
if beTLSPolicy != nil {
420420
beTLSPolicy.IsReferenced = true
421421
if !beTLSPolicy.Valid {
422-
err = fmt.Errorf("the backend TLS policy is invalid: %s", beTLSPolicy.Conditions[0].Message)
422+
//nolint:staticcheck // Capitalization required for alignment with other messages.
423+
err = fmt.Errorf("The backend TLS policy is invalid: %s", beTLSPolicy.Conditions[0].Message)
423424
} else {
424425
beTLSPolicy.Conditions = append(beTLSPolicy.Conditions, conditions.NewPolicyAccepted())
425426
}

internal/controller/state/graph/backend_refs_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ func TestAddBackendRefsToRules(t *testing.T) {
884884
Type: "Accepted",
885885
Status: "True",
886886
Reason: "Accepted",
887-
Message: "Policy is accepted",
887+
Message: "The Policy is accepted",
888888
},
889889
},
890890
Valid: true,
@@ -899,7 +899,7 @@ func TestAddBackendRefsToRules(t *testing.T) {
899899
Type: "Accepted",
900900
Status: "True",
901901
Reason: "Accepted",
902-
Message: "Policy is accepted",
902+
Message: "The Policy is accepted",
903903
},
904904
)
905905
btpWSS := getBtp("btpWSS", "svcWSS", "test")
@@ -1406,7 +1406,7 @@ func TestCreateBackend(t *testing.T) {
14061406
},
14071407
Valid: false,
14081408
Conditions: []conditions.Condition{
1409-
conditions.NewPolicyInvalid("unsupported value"),
1409+
conditions.NewPolicyInvalid("Unsupported value"),
14101410
},
14111411
}
14121412

@@ -1573,7 +1573,7 @@ func TestCreateBackend(t *testing.T) {
15731573
expectedServicePortReference: "",
15741574
expectedConditions: []conditions.Condition{
15751575
conditions.NewRouteBackendRefUnsupportedValue(
1576-
"the backend TLS policy is invalid: unsupported value",
1576+
"The backend TLS policy is invalid: Unsupported value",
15771577
),
15781578
},
15791579
name: "invalid policy",

0 commit comments

Comments
 (0)