Skip to content

Commit e020cf6

Browse files
committed
grpcservice: align with finalized AllowedGRPCService API
1 parent 3132e3d commit e020cf6

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

internal/xds/bootstrap/bootstrap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,10 @@ func (c *Config) AllowedGRPCServices() AllowedGRPCServices {
643643
return c.allowedGRPCServices
644644
}
645645

646-
// AllowedGrpcService returns the allowed gRPC service configured for the
646+
// AllowedGRPCService returns the allowed gRPC service configured for the
647647
// given target URI, if any.
648-
func (c *Config) AllowedGrpcService(targetURI string) (*AllowedGrpcService, bool) {
649-
svc, ok := c.allowedGrpcServices[targetURI]
648+
func (c *Config) AllowedGRPCService(targetURI string) (*AllowedGRPCService, bool) {
649+
svc, ok := c.allowedGRPCServices[targetURI]
650650
return svc, ok
651651
}
652652

internal/xds/grpcservice/grpcservice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (g *GrpcService) Parse(gs *v3corepb.GrpcService) (Config, error) {
116116
// allowlist, but the credentials themselves are resolved later,
117117
// at channel creation time; they are left empty in the parsed
118118
// config here.
119-
allowedSvc, ok := g.config.AllowedGrpcService(targetURI)
119+
allowedSvc, ok := g.config.AllowedGRPCService(targetURI)
120120
if !ok {
121121
return Config{}, fmt.Errorf("grpcservice: target_uri %q is not present in allowed_grpc_services", targetURI)
122122
}

internal/xds/grpcservice/grpcservice_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525

2626
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
2727
"github.com/google/go-cmp/cmp"
28+
"google.golang.org/grpc/internal/envconfig"
29+
"google.golang.org/grpc/internal/testutils"
2830
"google.golang.org/grpc/internal/xds/bootstrap"
2931
"google.golang.org/grpc/metadata"
3032
"google.golang.org/protobuf/types/known/anypb"
@@ -40,7 +42,7 @@ func bootstrapConfig(t *testing.T, allowed string) *bootstrap.Config {
4042
contents, err := bootstrap.NewContentsForTesting(bootstrap.ConfigOptionsForTesting{
4143
Servers: json.RawMessage(`[{"server_uri":"td.googleapis.com:443","channel_creds":[{"type":"insecure"}]}]`),
4244
Node: json.RawMessage(`{}`),
43-
AllowedGrpcServices: json.RawMessage(allowed),
45+
AllowedGRPCServices: json.RawMessage(allowed),
4446
})
4547
if err != nil {
4648
t.Fatalf("NewContentsForTesting() failed: %v", err)
@@ -65,6 +67,10 @@ func googleGrpcService(target string, channelPlugins []*anypb.Any, timeout *dura
6567
}
6668

6769
func TestParse(t *testing.T) {
70+
// The allowed_grpc_services bootstrap field is parsed only when a
71+
// consuming feature is enabled.
72+
testutils.SetEnvConfig(t, &envconfig.XDSClientExtProcEnabled, true)
73+
6874
insecurePlugin := &anypb.Any{TypeUrl: insecureCredsTypeURL}
6975
allowedInsecure := `{"dns:///my-service:443":{"channel_creds":[{"type":"insecure"}]}}`
7076

0 commit comments

Comments
 (0)