Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions internal/controller/nginx/config/policies/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ var _ = Describe("Policy CompositeValidator", func() {
policies.ManagerConfig{
Validator: &policiesfakes.FakeValidator{
ValidateStub: func(_ policies.Policy) []conditions.Condition {
return []conditions.Condition{conditions.NewPolicyInvalid("apple error")}
return []conditions.Condition{conditions.NewPolicyInvalid("Apple error")}
},
ValidateGlobalSettingsStub: func(_ policies.Policy, _ *policies.GlobalSettings) []conditions.Condition {
return []conditions.Condition{conditions.NewPolicyInvalid("apple global settings error")}
return []conditions.Condition{conditions.NewPolicyInvalid("Apple global settings error")}
},
ConflictsStub: func(_ policies.Policy, _ policies.Policy) bool { return true },
},
Expand All @@ -61,10 +61,10 @@ var _ = Describe("Policy CompositeValidator", func() {
policies.ManagerConfig{
Validator: &policiesfakes.FakeValidator{
ValidateStub: func(_ policies.Policy) []conditions.Condition {
return []conditions.Condition{conditions.NewPolicyInvalid("orange error")}
return []conditions.Condition{conditions.NewPolicyInvalid("Orange error")}
},
ValidateGlobalSettingsStub: func(_ policies.Policy, _ *policies.GlobalSettings) []conditions.Condition {
return []conditions.Condition{conditions.NewPolicyInvalid("orange global settings error")}
return []conditions.Condition{conditions.NewPolicyInvalid("Orange global settings error")}
},
ConflictsStub: func(_ policies.Policy, _ policies.Policy) bool { return false },
},
Expand All @@ -83,19 +83,18 @@ var _ = Describe("Policy CompositeValidator", func() {

conds := mgr.Validate(applePolicy)
Expect(conds).To(HaveLen(1))
Expect(conds[0].Message).To(Equal("apple error"))
Expect(conds[0].Message).To(Equal("Apple error"))

conds = mgr.ValidateGlobalSettings(applePolicy, globalSettings)
Expect(conds).To(HaveLen(1))
Expect(conds[0].Message).To(Equal("apple global settings error"))

Expect(conds[0].Message).To(Equal("Apple global settings error"))
conds = mgr.Validate(orangePolicy)
Expect(conds).To(HaveLen(1))
Expect(conds[0].Message).To(Equal("orange error"))
Expect(conds[0].Message).To(Equal("Orange error"))

conds = mgr.ValidateGlobalSettings(orangePolicy, globalSettings)
Expect(conds).To(HaveLen(1))
Expect(conds[0].Message).To(Equal("orange global settings error"))
Expect(conds[0].Message).To(Equal("Orange global settings error"))
})
It("Returns whether the policies conflict", func() {
Expect(mgr.Conflicts(applePolicy, applePolicy)).To(BeTrue())
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/state/change_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ var _ = Describe("ChangeProcessor", func() {
expGraph.GatewayClass = nil

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

Expand Down Expand Up @@ -2253,7 +2253,7 @@ var _ = Describe("ChangeProcessor", func() {
},
},
},
Conditions: conditions.NewGatewayInvalid("GatewayClass doesn't exist"),
Conditions: conditions.NewGatewayInvalid("The GatewayClass doesn't exist"),
DeploymentName: types.NamespacedName{
Namespace: "test",
Name: "gateway-2-test-class",
Expand Down
68 changes: 34 additions & 34 deletions internal/controller/state/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ func NewDefaultGatewayClassConditions() []Condition {
Type: string(v1.GatewayClassConditionStatusAccepted),
Status: metav1.ConditionTrue,
Reason: string(v1.GatewayClassReasonAccepted),
Message: "GatewayClass is accepted",
Message: "The GatewayClass is accepted",
},
{
Type: string(v1.GatewayClassConditionStatusSupportedVersion),
Status: metav1.ConditionTrue,
Reason: string(v1.GatewayClassReasonSupportedVersion),
Message: "Gateway API CRD versions are supported",
Message: "The Gateway API CRD versions are supported",
},
}
}
Expand All @@ -260,7 +260,7 @@ func NewGatewayClassSupportedVersionBestEffort(recommendedVersion string) []Cond
Status: metav1.ConditionFalse,
Reason: string(v1.GatewayClassReasonUnsupportedVersion),
Message: fmt.Sprintf(
"Gateway API CRD versions are not recommended. Recommended version is %s",
"The Gateway API CRD versions are not recommended. Recommended version is %s",
recommendedVersion,
),
},
Expand All @@ -276,7 +276,7 @@ func NewGatewayClassUnsupportedVersion(recommendedVersion string) []Condition {
Status: metav1.ConditionFalse,
Reason: string(v1.GatewayClassReasonUnsupportedVersion),
Message: fmt.Sprintf(
"Gateway API CRD versions are not supported. Please install version %s",
"The Gateway API CRD versions are not supported. Please install version %s",
recommendedVersion,
),
},
Expand All @@ -285,7 +285,7 @@ func NewGatewayClassUnsupportedVersion(recommendedVersion string) []Condition {
Status: metav1.ConditionFalse,
Reason: string(v1.GatewayClassReasonUnsupportedVersion),
Message: fmt.Sprintf(
"Gateway API CRD versions are not supported. Please install version %s",
"The Gateway API CRD versions are not supported. Please install version %s",
recommendedVersion,
),
},
Expand Down Expand Up @@ -318,18 +318,18 @@ func NewRouteNotAllowedByListeners() Condition {
Type: string(v1.RouteConditionAccepted),
Status: metav1.ConditionFalse,
Reason: string(v1.RouteReasonNotAllowedByListeners),
Message: "Route is not allowed by any listener",
Message: "The Route is not allowed by any listener",
}
}

// NewRouteNoMatchingListenerHostname returns a Condition that indicates that the hostname of the listener
// NewRouteNoMatchingListenerHostname returns a Condition that indicates that the hostname of the Listener
// does not match the hostnames of the Route.
func NewRouteNoMatchingListenerHostname() Condition {
return Condition{
Type: string(v1.RouteConditionAccepted),
Status: metav1.ConditionFalse,
Reason: string(v1.RouteReasonNoMatchingListenerHostname),
Message: "Listener hostname does not match the Route hostnames",
Message: "The Listener hostname does not match the Route hostnames",
}
}

Expand All @@ -339,7 +339,7 @@ func NewRouteAccepted() Condition {
Type: string(v1.RouteConditionAccepted),
Status: metav1.ConditionTrue,
Reason: string(v1.RouteReasonAccepted),
Message: "The route is accepted",
Message: "The Route is accepted",
}
}

Expand Down Expand Up @@ -386,7 +386,7 @@ func NewRouteInvalidListener() Condition {
Type: string(v1.RouteConditionAccepted),
Status: metav1.ConditionFalse,
Reason: string(RouteReasonInvalidListener),
Message: "Listener is invalid for this parent ref",
Message: "The Listener is invalid for this parent ref",
}
}

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

Expand Down Expand Up @@ -484,7 +484,7 @@ func NewRouteInvalidGateway() Condition {
Type: string(v1.RouteConditionAccepted),
Status: metav1.ConditionFalse,
Reason: string(RouteReasonInvalidGateway),
Message: "Gateway is invalid",
Message: "The Gateway is invalid",
}
}

Expand All @@ -495,7 +495,7 @@ func NewRouteNoMatchingParent() Condition {
Type: string(v1.RouteConditionAccepted),
Status: metav1.ConditionFalse,
Reason: string(v1.RouteReasonNoMatchingParent),
Message: "Listener is not found for this parent ref",
Message: "The Listener is not found for this parent ref",
}
}

Expand Down Expand Up @@ -550,7 +550,7 @@ func NewDefaultListenerConditions(existingConditions []Condition) []Condition {
return defaultConds
}

// hasConflictConditions checks if the listener has any conflict-related conditions.
// hasConflictConditions checks if the Listener has any conflict-related conditions.
func hasConflictConditions(conditions []Condition) bool {
for _, cond := range conditions {
if cond.Type == string(v1.ListenerConditionConflicted) ||
Expand All @@ -567,7 +567,7 @@ func NewListenerAccepted() Condition {
Type: string(v1.ListenerConditionAccepted),
Status: metav1.ConditionTrue,
Reason: string(v1.ListenerReasonAccepted),
Message: "Listener is accepted",
Message: "The Listener is accepted",
}
}

Expand All @@ -577,7 +577,7 @@ func NewListenerProgrammed() Condition {
Type: string(v1.ListenerConditionProgrammed),
Status: metav1.ConditionTrue,
Reason: string(v1.ListenerReasonProgrammed),
Message: "Listener is programmed",
Message: "The Listener is programmed",
}
}

Expand Down Expand Up @@ -750,7 +750,7 @@ func NewGatewayClassResolvedRefs() Condition {
Type: string(GatewayClassResolvedRefs),
Status: metav1.ConditionTrue,
Reason: string(GatewayClassReasonResolvedRefs),
Message: "ParametersRef resource is resolved",
Message: "The ParametersRef resource is resolved",
}
}

Expand All @@ -761,7 +761,7 @@ func NewGatewayClassRefNotFound() Condition {
Type: string(GatewayClassResolvedRefs),
Status: metav1.ConditionFalse,
Reason: string(GatewayClassReasonParamsRefNotFound),
Message: "ParametersRef resource could not be found",
Message: "The ParametersRef resource could not be found",
}
}

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

Expand All @@ -802,7 +802,7 @@ func NewGatewayAccepted() Condition {
Type: string(v1.GatewayConditionAccepted),
Status: metav1.ConditionTrue,
Reason: string(v1.GatewayReasonAccepted),
Message: "Gateway is accepted",
Message: "The Gateway is accepted",
}
}

Expand All @@ -813,14 +813,14 @@ func NewGatewayAcceptedListenersNotValid() Condition {
Type: string(v1.GatewayConditionAccepted),
Status: metav1.ConditionTrue,
Reason: string(v1.GatewayReasonListenersNotValid),
Message: "Gateway has at least one valid listener",
Message: "The Gateway has at least one valid listener",
}
}

// NewGatewayNotAcceptedListenersNotValid returns Conditions that indicate the Gateway is not accepted,
// because all listeners are invalid.
func NewGatewayNotAcceptedListenersNotValid() []Condition {
msg := "Gateway has no valid listeners"
msg := "The Gateway has no valid listeners"
return []Condition{
{
Type: string(v1.GatewayConditionAccepted),
Expand Down Expand Up @@ -885,7 +885,7 @@ func NewGatewayProgrammed() Condition {
Type: string(v1.GatewayConditionProgrammed),
Status: metav1.ConditionTrue,
Reason: string(v1.GatewayReasonProgrammed),
Message: "Gateway is programmed",
Message: "The Gateway is programmed",
}
}

Expand All @@ -907,7 +907,7 @@ func NewNginxGatewayValid() Condition {
Type: string(ngfAPI.NginxGatewayConditionValid),
Status: metav1.ConditionTrue,
Reason: string(ngfAPI.NginxGatewayReasonValid),
Message: "NginxGateway is valid",
Message: "The NginxGateway is valid",
}
}

Expand All @@ -928,7 +928,7 @@ func NewGatewayResolvedRefs() Condition {
Type: string(GatewayResolvedRefs),
Status: metav1.ConditionTrue,
Reason: string(GatewayReasonResolvedRefs),
Message: "ParametersRef resource is resolved",
Message: "The ParametersRef resource is resolved",
}
}

Expand All @@ -939,7 +939,7 @@ func NewGatewayRefNotFound() Condition {
Type: string(GatewayResolvedRefs),
Status: metav1.ConditionFalse,
Reason: string(GatewayReasonParamsRefNotFound),
Message: "ParametersRef resource could not be found",
Message: "The ParametersRef resource could not be found",
}
}

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

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

Expand All @@ -983,7 +983,7 @@ func NewPolicyAccepted() Condition {
Type: string(v1.PolicyConditionAccepted),
Status: metav1.ConditionTrue,
Reason: string(v1.PolicyReasonAccepted),
Message: "Policy is accepted",
Message: "The Policy is accepted",
}
}

Expand Down Expand Up @@ -1071,7 +1071,7 @@ func NewSnippetsFilterAccepted() Condition {
Type: string(ngfAPI.SnippetsFilterConditionTypeAccepted),
Status: metav1.ConditionTrue,
Reason: string(ngfAPI.SnippetsFilterConditionReasonAccepted),
Message: "SnippetsFilter is accepted",
Message: "The SnippetsFilter is accepted",
}
}

Expand All @@ -1082,7 +1082,7 @@ func NewObservabilityPolicyAffected() Condition {
Type: string(ObservabilityPolicyAffected),
Status: metav1.ConditionTrue,
Reason: string(PolicyAffectedReason),
Message: "ObservabilityPolicy is applied to the resource",
Message: "The ObservabilityPolicy is applied to the resource",
}
}

Expand All @@ -1093,7 +1093,7 @@ func NewClientSettingsPolicyAffected() Condition {
Type: string(ClientSettingsPolicyAffected),
Status: metav1.ConditionTrue,
Reason: string(PolicyAffectedReason),
Message: "ClientSettingsPolicy is applied to the resource",
Message: "The ClientSettingsPolicy is applied to the resource",
}
}

Expand Down Expand Up @@ -1147,7 +1147,7 @@ func NewInferencePoolAccepted() Condition {
Type: string(inference.InferencePoolConditionAccepted),
Status: metav1.ConditionTrue,
Reason: string(inference.InferencePoolConditionAccepted),
Message: "InferencePool is accepted by the Gateway.",
Message: "The InferencePool is accepted by the Gateway.",
}
}

Expand All @@ -1158,7 +1158,7 @@ func NewInferencePoolResolvedRefs() Condition {
Type: string(inference.InferencePoolConditionResolvedRefs),
Status: metav1.ConditionTrue,
Reason: string(inference.InferencePoolConditionResolvedRefs),
Message: "Inference pool references a valid ExtensionRef.",
Message: "The InferencePool references a valid ExtensionRef.",
}
}

Expand Down
Loading
Loading