Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions apis/v1alpha2/grpcroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ type GRPCRouteRule struct {
// - Implementation-specific custom filters have no API guarantees across
// implementations.
//
// Specifying a core filter multiple times has unspecified or
// implementation-specific conformance.
// Specifying the same filter multiple times is not supported unless explicitly
// indicated in the filter.
//
// If an implementation can not support a combinations of filters, they must clearly
// document that limitation. In cases where incompatible or unsupported
Expand Down Expand Up @@ -515,6 +515,10 @@ type GRPCRouteFilter struct {
// Requests are sent to the specified destination, but responses from
// that destination are ignored.
//
// This filter can be used multiple times within the same rule. Note that
// not all implementations will be able to support mirroring to multiple
// backends.
//
// Support: Extended
//
// +optional
Expand All @@ -527,6 +531,7 @@ type GRPCRouteFilter struct {
//
// Support: Implementation-specific
//
// This filter can be used multiple times within the same rule.
// +optional
ExtensionRef *LocalObjectReference `json:"extensionRef,omitempty"`
}
Expand Down
3 changes: 2 additions & 1 deletion apis/v1alpha2/validation/grpcroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
// repeated multiple times in a rule.
repeatableGRPCRouteFilters = []gatewayv1a2.GRPCRouteFilterType{
gatewayv1a2.GRPCRouteFilterExtensionRef,
gatewayv1a2.GRPCRouteFilterRequestMirror,
}
validServiceName = `^(?i)\.?[a-z_][a-z_0-9]*(\.[a-z_][a-z_0-9]*)*$`
validServiceNameRegex = regexp.MustCompile(validServiceName)
Expand Down Expand Up @@ -165,7 +166,7 @@ func validateGRPCRouteFilters(filters []gatewayv1a2.GRPCRouteFilter, path *field
}
errs = append(errs, validateGRPCRouteFilterType(filter, path.Index(i))...)
}
// custom filters don't have any validation
// repeatableHTTPRouteFilters filters can be used more than once
for _, key := range repeatableGRPCRouteFilters {
delete(counts, key)
}
Expand Down
34 changes: 31 additions & 3 deletions apis/v1alpha2/validation/grpcroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,38 @@ func TestValidateGRPCRoute(t *testing.T) {
}},
},
},
},
{
name: "invalid GRPCRoute with duplicate RequestHeaderModifier filters",
rules: []gatewayv1a2.GRPCRouteRule{
{
Filters: []gatewayv1a2.GRPCRouteFilter{{
Type: "RequestHeaderModifier",
RequestHeaderModifier: &gatewayv1a2.HTTPHeaderFilter{
Set: []gatewayv1a2.HTTPHeader{
{
Name: "special-header",
Value: "foo",
},
},
},
}, {
Type: "RequestHeaderModifier",
RequestHeaderModifier: &gatewayv1a2.HTTPRequesHTTPHeaderFiltertMirrorFilter{
Add: []gatewayv1a2.HTTPHeader{
{
Name: "my-header",
Value: "bar",
},
},
},
}},
},
},
errs: field.ErrorList{
{
Type: field.ErrorTypeInvalid,
BadValue: "RequestMirror",
BadValue: "RequestHeaderModifier",
Field: "spec.rules[0].filters",
Detail: "cannot be used multiple times in the same rule",
},
Expand Down Expand Up @@ -305,8 +333,8 @@ func TestValidateGRPCBackendUniqueFilters(t *testing.T) {
},
}},
}, {
name: "invalid grpcRoute Rules duplicate mirror filter",
errCount: 1,
name: "valid grpcRoute Rules duplicate mirror filter",
errCount: 0,
rules: []gatewayv1a2.GRPCRouteRule{{
BackendRefs: []gatewayv1a2.GRPCBackendRef{
{
Expand Down
21 changes: 15 additions & 6 deletions config/crd/experimental/gateway.networking.k8s.io_grpcroutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.