Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Mar 1, 2021
1 parent 1547299 commit ce44983
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions xds/internal/client/lds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
Name: "serverOnlyCustomFilter",
ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: serverOnlyCustomFilterConfig},
}
serverOnlyOptionalCustomFilter = &v3httppb.HttpFilter{
Name: "serverOnlyOptionalCustomFilter",
ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: serverOnlyCustomFilterConfig},
IsOptional: true,
}
unknownFilter = &v3httppb.HttpFilter{
Name: "unknownFilter",
ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: unknownFilterConfig},
Expand Down Expand Up @@ -412,6 +417,15 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
resources: []*anypb.Any{v3LisWithFilters(serverOnlyCustomFilter)},
wantErr: true,
},
{
name: "v3 with optional server-only filter",
resources: []*anypb.Any{v3LisWithFilters(serverOnlyOptionalCustomFilter)},
wantUpdate: map[string]ListenerUpdate{
v3LDSTarget: {
RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second,
},
},
},
{
name: "v3 with client-only filter",
resources: []*anypb.Any{v3LisWithFilters(clientOnlyCustomFilter)},
Expand Down
6 changes: 6 additions & 0 deletions xds/internal/client/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,15 @@ func processHTTPFilters(filters []*v3httppb.HttpFilter, server bool) ([]HTTPFilt
}
if server {
if _, ok := httpFilter.(httpfilter.ServerInterceptorBuilder); !ok {
if filter.GetIsOptional() {
continue
}
return nil, fmt.Errorf("HTTP filter %q not supported server-side", name)
}
} else if _, ok := httpFilter.(httpfilter.ClientInterceptorBuilder); !ok {
if filter.GetIsOptional() {
continue
}
return nil, fmt.Errorf("HTTP filter %q not supported client-side", name)
}

Expand Down

0 comments on commit ce44983

Please sign in to comment.