diff --git a/internal/xds/env/env.go b/internal/envconfig/xds.go similarity index 96% rename from internal/xds/env/env.go rename to internal/envconfig/xds.go index 235feb8e0154..be568184ca00 100644 --- a/internal/xds/env/env.go +++ b/internal/envconfig/xds.go @@ -16,9 +16,7 @@ * */ -// Package env acts a single source of definition for all environment variables -// related to the xDS implementation in gRPC. -package env +package envconfig import ( "os" diff --git a/internal/xds/bootstrap.go b/internal/xds/bootstrap.go index 1d74ab46a114..b3146386f506 100644 --- a/internal/xds/bootstrap.go +++ b/internal/xds/bootstrap.go @@ -27,7 +27,7 @@ import ( "os" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal/xds/env" + "google.golang.org/grpc/internal/envconfig" ) var logger = grpclog.Component("internal/xds") @@ -79,11 +79,11 @@ func SetupBootstrapFile(opts BootstrapOptions) (func(), error) { } logger.Infof("Created bootstrap file at %q with contents: %s\n", f.Name(), bootstrapContents) - origBootstrapFileName := env.BootstrapFileName - env.BootstrapFileName = f.Name() + origBootstrapFileName := envconfig.BootstrapFileName + envconfig.BootstrapFileName = f.Name() return func() { os.Remove(f.Name()) - env.BootstrapFileName = origBootstrapFileName + envconfig.BootstrapFileName = origBootstrapFileName }, nil } diff --git a/xds/googledirectpath/googlec2p.go b/xds/googledirectpath/googlec2p.go index b9f1c712014e..e77758d61508 100644 --- a/xds/googledirectpath/googlec2p.go +++ b/xds/googledirectpath/googlec2p.go @@ -29,20 +29,21 @@ import ( "fmt" "time" - v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" "google.golang.org/grpc" "google.golang.org/grpc/credentials/google" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/internal/googlecloud" internalgrpclog "google.golang.org/grpc/internal/grpclog" "google.golang.org/grpc/internal/grpcrand" - "google.golang.org/grpc/internal/xds/env" "google.golang.org/grpc/resolver" _ "google.golang.org/grpc/xds" // To register xds resolvers and balancers. "google.golang.org/grpc/xds/internal/version" "google.golang.org/grpc/xds/internal/xdsclient" "google.golang.org/grpc/xds/internal/xdsclient/bootstrap" "google.golang.org/protobuf/types/known/structpb" + + v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" ) const ( @@ -74,7 +75,7 @@ var ( ) func init() { - if env.C2PResolverSupport { + if envconfig.C2PResolverSupport { resolver.Register(c2pResolverBuilder{}) } } @@ -98,7 +99,7 @@ func (c2pResolverBuilder) Build(t resolver.Target, cc resolver.ClientConn, opts go func() { zoneCh <- getZone(httpReqTimeout) }() go func() { ipv6CapableCh <- getIPv6Capable(httpReqTimeout) }() - balancerName := env.C2PResolverTestOnlyTrafficDirectorURI + balancerName := envconfig.C2PResolverTestOnlyTrafficDirectorURI if balancerName == "" { balancerName = tdURL } @@ -174,5 +175,5 @@ func newNode(zone string, ipv6Capable bool) *v3corepb.Node { // direct path is enabled if this client is running on GCE, and the normal xDS // is not used (bootstrap env vars are not set). func runDirectPath() bool { - return env.BootstrapFileName == "" && env.BootstrapFileContent == "" && onGCE() + return envconfig.BootstrapFileName == "" && envconfig.BootstrapFileContent == "" && onGCE() } diff --git a/xds/googledirectpath/googlec2p_test.go b/xds/googledirectpath/googlec2p_test.go index a208fad66c58..f8c1371918d9 100644 --- a/xds/googledirectpath/googlec2p_test.go +++ b/xds/googledirectpath/googlec2p_test.go @@ -23,17 +23,18 @@ import ( "testing" "time" - v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/grpc" - "google.golang.org/grpc/internal/xds/env" + "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/resolver" "google.golang.org/grpc/xds/internal/version" "google.golang.org/grpc/xds/internal/xdsclient" "google.golang.org/grpc/xds/internal/xdsclient/bootstrap" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/known/structpb" + + v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" ) type emptyResolver struct { @@ -90,7 +91,7 @@ func TestBuildWithBootstrapEnvSet(t *testing.T) { defer replaceResolvers()() builder := resolver.Get(c2pScheme) - for i, envP := range []*string{&env.BootstrapFileName, &env.BootstrapFileContent} { + for i, envP := range []*string{&envconfig.BootstrapFileName, &envconfig.BootstrapFileContent} { t.Run(strconv.Itoa(i), func(t *testing.T) { // Set bootstrap config env var. oldEnv := *envP @@ -166,10 +167,10 @@ func TestBuildXDS(t *testing.T) { defer func() { getIPv6Capable = oldGetIPv6Capability }() if tt.tdURI != "" { - oldURI := env.C2PResolverTestOnlyTrafficDirectorURI - env.C2PResolverTestOnlyTrafficDirectorURI = tt.tdURI + oldURI := envconfig.C2PResolverTestOnlyTrafficDirectorURI + envconfig.C2PResolverTestOnlyTrafficDirectorURI = tt.tdURI defer func() { - env.C2PResolverTestOnlyTrafficDirectorURI = oldURI + envconfig.C2PResolverTestOnlyTrafficDirectorURI = oldURI }() } diff --git a/xds/internal/resolver/serviceconfig.go b/xds/internal/resolver/serviceconfig.go index ddf699f938b3..50e7f7b71728 100644 --- a/xds/internal/resolver/serviceconfig.go +++ b/xds/internal/resolver/serviceconfig.go @@ -29,11 +29,11 @@ import ( xxhash "github.com/cespare/xxhash/v2" "google.golang.org/grpc/codes" + "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/internal/grpcrand" iresolver "google.golang.org/grpc/internal/resolver" "google.golang.org/grpc/internal/serviceconfig" "google.golang.org/grpc/internal/wrr" - "google.golang.org/grpc/internal/xds/env" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/grpc/xds/internal/balancer/clustermanager" @@ -174,7 +174,7 @@ func (cs *configSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RP lbCtx := clustermanager.SetPickedCluster(rpcInfo.Context, cluster.name) // Request Hashes are only applicable for a Ring Hash LB. - if env.RingHashSupport { + if envconfig.RingHashSupport { lbCtx = ringhash.SetRequestHash(lbCtx, cs.generateHash(rpcInfo, rt.hashPolicies)) } diff --git a/xds/internal/resolver/xds_resolver_test.go b/xds/internal/resolver/xds_resolver_test.go index 90e6c1d4db05..6bf25973234b 100644 --- a/xds/internal/resolver/xds_resolver_test.go +++ b/xds/internal/resolver/xds_resolver_test.go @@ -32,12 +32,12 @@ import ( "google.golang.org/grpc/credentials/insecure" xdscreds "google.golang.org/grpc/credentials/xds" "google.golang.org/grpc/internal" + "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/internal/grpcrand" "google.golang.org/grpc/internal/grpctest" iresolver "google.golang.org/grpc/internal/resolver" "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/internal/wrr" - "google.golang.org/grpc/internal/xds/env" "google.golang.org/grpc/metadata" "google.golang.org/grpc/resolver" "google.golang.org/grpc/serviceconfig" @@ -460,9 +460,9 @@ func (s) TestXDSResolverGoodServiceUpdate(t *testing.T) { // with a HashPolicy specifying to generate a hash. The configSelector generated should // successfully generate a Hash. func (s) TestXDSResolverRequestHash(t *testing.T) { - oldRH := env.RingHashSupport - env.RingHashSupport = true - defer func() { env.RingHashSupport = oldRH }() + oldRH := envconfig.RingHashSupport + envconfig.RingHashSupport = true + defer func() { envconfig.RingHashSupport = oldRH }() xdsC := fakeclient.NewClient() xdsR, tcc, cancel := testSetup(t, setupOpts{ diff --git a/xds/internal/test/xds_client_affinity_test.go b/xds/internal/test/xds_client_affinity_test.go index e9ddfe157b12..b6565025d17f 100644 --- a/xds/internal/test/xds_client_affinity_test.go +++ b/xds/internal/test/xds_client_affinity_test.go @@ -26,14 +26,15 @@ import ( "fmt" "testing" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/internal/envconfig" + "google.golang.org/grpc/xds/internal/testutils/e2e" + v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/internal/xds/env" testpb "google.golang.org/grpc/test/grpc_testing" - "google.golang.org/grpc/xds/internal/testutils/e2e" ) const hashHeaderName = "session_id" @@ -86,9 +87,9 @@ func ringhashCluster(clusterName, edsServiceName string) *v3clusterpb.Cluster { // behavior in ring_hash policy. func (s) TestClientSideAffinitySanityCheck(t *testing.T) { defer func() func() { - old := env.RingHashSupport - env.RingHashSupport = true - return func() { env.RingHashSupport = old } + old := envconfig.RingHashSupport + envconfig.RingHashSupport = true + return func() { envconfig.RingHashSupport = old } }()() managementServer, nodeID, _, resolver, cleanup1 := setupManagementServer(t) diff --git a/xds/internal/xdsclient/bootstrap/bootstrap.go b/xds/internal/xdsclient/bootstrap/bootstrap.go index fa229d99593e..985c5f7f45cf 100644 --- a/xds/internal/xdsclient/bootstrap/bootstrap.go +++ b/xds/internal/xdsclient/bootstrap/bootstrap.go @@ -26,8 +26,6 @@ import ( "fmt" "io/ioutil" - v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" - v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" "google.golang.org/grpc" @@ -35,9 +33,12 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/tls/certprovider" "google.golang.org/grpc/internal" + "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/internal/pretty" - "google.golang.org/grpc/internal/xds/env" "google.golang.org/grpc/xds/internal/version" + + v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" + v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" ) const ( @@ -100,8 +101,8 @@ type xdsServer struct { } func bootstrapConfigFromEnvVariable() ([]byte, error) { - fName := env.BootstrapFileName - fContent := env.BootstrapFileContent + fName := envconfig.BootstrapFileName + fContent := envconfig.BootstrapFileContent // Bootstrap file name has higher priority than bootstrap content. if fName != "" { @@ -119,7 +120,8 @@ func bootstrapConfigFromEnvVariable() ([]byte, error) { return []byte(fContent), nil } - return nil, fmt.Errorf("none of the bootstrap environment variables (%q or %q) defined", env.BootstrapFileNameEnv, env.BootstrapFileContentEnv) + return nil, fmt.Errorf("none of the bootstrap environment variables (%q or %q) defined", + envconfig.BootstrapFileNameEnv, envconfig.BootstrapFileContentEnv) } // NewConfig returns a new instance of Config initialized by reading the diff --git a/xds/internal/xdsclient/bootstrap/bootstrap_test.go b/xds/internal/xdsclient/bootstrap/bootstrap_test.go index 501d62102d21..b201d14ed62b 100644 --- a/xds/internal/xdsclient/bootstrap/bootstrap_test.go +++ b/xds/internal/xdsclient/bootstrap/bootstrap_test.go @@ -25,10 +25,7 @@ import ( "os" "testing" - v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" - v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" "github.com/golang/protobuf/proto" - structpb "github.com/golang/protobuf/ptypes/struct" "github.com/google/go-cmp/cmp" "google.golang.org/grpc" @@ -36,8 +33,12 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/tls/certprovider" "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/xds/env" + "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/xds/internal/version" + + v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" + v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" + structpb "github.com/golang/protobuf/ptypes/struct" ) var ( @@ -285,9 +286,9 @@ func setupBootstrapOverride(bootstrapFileMap map[string]string) func() { // This function overrides the bootstrap file NAME env variable, to test the // code that reads file with the given fileName. func testNewConfigWithFileNameEnv(t *testing.T, fileName string, wantError bool, wantConfig *Config) { - origBootstrapFileName := env.BootstrapFileName - env.BootstrapFileName = fileName - defer func() { env.BootstrapFileName = origBootstrapFileName }() + origBootstrapFileName := envconfig.BootstrapFileName + envconfig.BootstrapFileName = fileName + defer func() { envconfig.BootstrapFileName = origBootstrapFileName }() c, err := NewConfig() if (err != nil) != wantError { @@ -309,9 +310,9 @@ func testNewConfigWithFileContentEnv(t *testing.T, fileName string, wantError bo // If file reading failed, skip this test. return } - origBootstrapContent := env.BootstrapFileContent - env.BootstrapFileContent = string(b) - defer func() { env.BootstrapFileContent = origBootstrapContent }() + origBootstrapContent := envconfig.BootstrapFileContent + envconfig.BootstrapFileContent = string(b) + defer func() { envconfig.BootstrapFileContent = origBootstrapContent }() c, err := NewConfig() if (err != nil) != wantError { @@ -472,13 +473,13 @@ func TestNewConfigBootstrapEnvPriority(t *testing.T) { goodFileContent2 := v3BootstrapFileMap[goodFileName2] goodConfig2 := nonNilCredsConfigV3 - origBootstrapFileName := env.BootstrapFileName - env.BootstrapFileName = "" - defer func() { env.BootstrapFileName = origBootstrapFileName }() + origBootstrapFileName := envconfig.BootstrapFileName + envconfig.BootstrapFileName = "" + defer func() { envconfig.BootstrapFileName = origBootstrapFileName }() - origBootstrapContent := env.BootstrapFileContent - env.BootstrapFileContent = "" - defer func() { env.BootstrapFileContent = origBootstrapContent }() + origBootstrapContent := envconfig.BootstrapFileContent + envconfig.BootstrapFileContent = "" + defer func() { envconfig.BootstrapFileContent = origBootstrapContent }() // When both env variables are empty, NewConfig should fail. if _, err := NewConfig(); err == nil { @@ -486,21 +487,21 @@ func TestNewConfigBootstrapEnvPriority(t *testing.T) { } // When one of them is set, it should be used. - env.BootstrapFileName = goodFileName1 - env.BootstrapFileContent = "" + envconfig.BootstrapFileName = goodFileName1 + envconfig.BootstrapFileContent = "" if c, err := NewConfig(); err != nil || c.compare(goodConfig1) != nil { t.Errorf("NewConfig() = %v, %v, want: %v, %v", c, err, goodConfig1, nil) } - env.BootstrapFileName = "" - env.BootstrapFileContent = goodFileContent2 + envconfig.BootstrapFileName = "" + envconfig.BootstrapFileContent = goodFileContent2 if c, err := NewConfig(); err != nil || c.compare(goodConfig2) != nil { t.Errorf("NewConfig() = %v, %v, want: %v, %v", c, err, goodConfig1, nil) } // Set both, file name should be read. - env.BootstrapFileName = goodFileName1 - env.BootstrapFileContent = goodFileContent2 + envconfig.BootstrapFileName = goodFileName1 + envconfig.BootstrapFileContent = goodFileContent2 if c, err := NewConfig(); err != nil || c.compare(goodConfig1) != nil { t.Errorf("NewConfig() = %v, %v, want: %v, %v", c, err, goodConfig1, nil) } diff --git a/xds/internal/xdsclient/cds_test.go b/xds/internal/xdsclient/cds_test.go index 21e3b05b9089..d3a93df3e61b 100644 --- a/xds/internal/xdsclient/cds_test.go +++ b/xds/internal/xdsclient/cds_test.go @@ -23,6 +23,14 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "google.golang.org/grpc/internal/envconfig" + "google.golang.org/grpc/internal/testutils" + "google.golang.org/grpc/internal/xds/matcher" + "google.golang.org/grpc/xds/internal/version" + "google.golang.org/protobuf/types/known/wrapperspb" + v2xdspb "github.com/envoyproxy/go-control-plane/envoy/api/v2" v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" @@ -32,13 +40,6 @@ import ( v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" v3matcherpb "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" anypb "github.com/golang/protobuf/ptypes/any" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "google.golang.org/grpc/internal/testutils" - "google.golang.org/grpc/internal/xds/env" - "google.golang.org/grpc/internal/xds/matcher" - "google.golang.org/grpc/xds/internal/version" - "google.golang.org/protobuf/types/known/wrapperspb" ) const ( @@ -194,12 +195,12 @@ func (s) TestValidateCluster_Failure(t *testing.T) { }, } - oldAggregateAndDNSSupportEnv := env.AggregateAndDNSSupportEnv - env.AggregateAndDNSSupportEnv = true - defer func() { env.AggregateAndDNSSupportEnv = oldAggregateAndDNSSupportEnv }() - oldRingHashSupport := env.RingHashSupport - env.RingHashSupport = true - defer func() { env.RingHashSupport = oldRingHashSupport }() + oldAggregateAndDNSSupportEnv := envconfig.AggregateAndDNSSupportEnv + envconfig.AggregateAndDNSSupportEnv = true + defer func() { envconfig.AggregateAndDNSSupportEnv = oldAggregateAndDNSSupportEnv }() + oldRingHashSupport := envconfig.RingHashSupport + envconfig.RingHashSupport = true + defer func() { envconfig.RingHashSupport = oldRingHashSupport }() for _, test := range tests { t.Run(test.name, func(t *testing.T) { if update, err := validateClusterAndConstructClusterUpdate(test.cluster); err == nil { @@ -414,12 +415,12 @@ func (s) TestValidateCluster_Success(t *testing.T) { }, } - oldAggregateAndDNSSupportEnv := env.AggregateAndDNSSupportEnv - env.AggregateAndDNSSupportEnv = true - defer func() { env.AggregateAndDNSSupportEnv = oldAggregateAndDNSSupportEnv }() - oldRingHashSupport := env.RingHashSupport - env.RingHashSupport = true - defer func() { env.RingHashSupport = oldRingHashSupport }() + oldAggregateAndDNSSupportEnv := envconfig.AggregateAndDNSSupportEnv + envconfig.AggregateAndDNSSupportEnv = true + defer func() { envconfig.AggregateAndDNSSupportEnv = oldAggregateAndDNSSupportEnv }() + oldRingHashSupport := envconfig.RingHashSupport + envconfig.RingHashSupport = true + defer func() { envconfig.RingHashSupport = oldRingHashSupport }() for _, test := range tests { t.Run(test.name, func(t *testing.T) { update, err := validateClusterAndConstructClusterUpdate(test.cluster) @@ -435,9 +436,9 @@ func (s) TestValidateCluster_Success(t *testing.T) { func (s) TestValidateClusterWithSecurityConfig_EnvVarOff(t *testing.T) { // Turn off the env var protection for client-side security. - origClientSideSecurityEnvVar := env.ClientSideSecuritySupport - env.ClientSideSecuritySupport = false - defer func() { env.ClientSideSecuritySupport = origClientSideSecurityEnvVar }() + origClientSideSecurityEnvVar := envconfig.ClientSideSecuritySupport + envconfig.ClientSideSecuritySupport = false + defer func() { envconfig.ClientSideSecuritySupport = origClientSideSecurityEnvVar }() cluster := &v3clusterpb.Cluster{ Name: clusterName, diff --git a/xds/internal/xdsclient/rds_test.go b/xds/internal/xdsclient/rds_test.go index c865bf36cfa7..c060060fbcd9 100644 --- a/xds/internal/xdsclient/rds_test.go +++ b/xds/internal/xdsclient/rds_test.go @@ -27,8 +27,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/grpc/codes" + "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/internal/testutils" - "google.golang.org/grpc/internal/xds/env" "google.golang.org/grpc/xds/internal/httpfilter" "google.golang.org/grpc/xds/internal/version" "google.golang.org/protobuf/types/known/durationpb" @@ -1454,9 +1454,9 @@ func (s) TestRoutesProtoToSlice(t *testing.T) { return fmt.Sprint(fc) }), } - oldRingHashSupport := env.RingHashSupport - env.RingHashSupport = true - defer func() { env.RingHashSupport = oldRingHashSupport }() + oldRingHashSupport := envconfig.RingHashSupport + envconfig.RingHashSupport = true + defer func() { envconfig.RingHashSupport = oldRingHashSupport }() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := routesProtoToSlice(tt.routes, nil, false) @@ -1567,9 +1567,9 @@ func (s) TestHashPoliciesProtoToSlice(t *testing.T) { }, } - oldRingHashSupport := env.RingHashSupport - env.RingHashSupport = true - defer func() { env.RingHashSupport = oldRingHashSupport }() + oldRingHashSupport := envconfig.RingHashSupport + envconfig.RingHashSupport = true + defer func() { envconfig.RingHashSupport = oldRingHashSupport }() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := hashPoliciesProtoToSlice(tt.hashPolicies, nil) diff --git a/xds/internal/xdsclient/xds.go b/xds/internal/xdsclient/xds.go index a838eb6b9950..1cd9d62bc06d 100644 --- a/xds/internal/xdsclient/xds.go +++ b/xds/internal/xdsclient/xds.go @@ -27,6 +27,19 @@ import ( "strings" "time" + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" + "google.golang.org/protobuf/types/known/anypb" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/internal/envconfig" + "google.golang.org/grpc/internal/grpclog" + "google.golang.org/grpc/internal/pretty" + "google.golang.org/grpc/internal/xds/matcher" + "google.golang.org/grpc/xds/internal" + "google.golang.org/grpc/xds/internal/httpfilter" + "google.golang.org/grpc/xds/internal/version" + v1udpatypepb "github.com/cncf/udpa/go/udpa/type/v1" v3cncftypepb "github.com/cncf/xds/go/xds/type/v3" v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" @@ -38,19 +51,6 @@ import ( v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" - "google.golang.org/protobuf/types/known/anypb" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/internal/pretty" - "google.golang.org/grpc/internal/xds/matcher" - - "google.golang.org/grpc/internal/grpclog" - "google.golang.org/grpc/internal/xds/env" - "google.golang.org/grpc/xds/internal" - "google.golang.org/grpc/xds/internal/httpfilter" - "google.golang.org/grpc/xds/internal/version" ) // TransportSocket proto message has a `name` field which is expected to be set @@ -549,7 +549,7 @@ func routesProtoToSlice(routes []*v3routepb.Route, logger *grpclog.PrefixLogger, action := r.GetRoute() // Hash Policies are only applicable for a Ring Hash LB. - if env.RingHashSupport { + if envconfig.RingHashSupport { hp, err := hashPoliciesProtoToSlice(action.HashPolicy, logger) if err != nil { return nil, err @@ -713,7 +713,7 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu case v3clusterpb.Cluster_ROUND_ROBIN: lbPolicy = nil // The default is round_robin, and there's no config to set. case v3clusterpb.Cluster_RING_HASH: - if !env.RingHashSupport { + if !envconfig.RingHashSupport { return ClusterUpdate{}, fmt.Errorf("unexpected lbPolicy %v in response: %+v", cluster.GetLbPolicy(), cluster) } rhc := cluster.GetRingHashLbConfig() @@ -746,7 +746,7 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu // Process security configuration received from the control plane iff the // corresponding environment variable is set. var sc *SecurityConfig - if env.ClientSideSecuritySupport { + if envconfig.ClientSideSecuritySupport { var err error if sc, err = securityConfigFromCluster(cluster); err != nil { return ClusterUpdate{}, err @@ -771,7 +771,7 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu ret.EDSServiceName = cluster.GetEdsClusterConfig().GetServiceName() return ret, nil case cluster.GetType() == v3clusterpb.Cluster_LOGICAL_DNS: - if !env.AggregateAndDNSSupportEnv { + if !envconfig.AggregateAndDNSSupportEnv { return ClusterUpdate{}, fmt.Errorf("unsupported cluster type (%v, %v) in response: %+v", cluster.GetType(), cluster.GetClusterType(), cluster) } ret.ClusterType = ClusterTypeLogicalDNS @@ -782,7 +782,7 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu ret.DNSHostName = dnsHN return ret, nil case cluster.GetClusterType() != nil && cluster.GetClusterType().Name == "envoy.clusters.aggregate": - if !env.AggregateAndDNSSupportEnv { + if !envconfig.AggregateAndDNSSupportEnv { return ClusterUpdate{}, fmt.Errorf("unsupported cluster type (%v, %v) in response: %+v", cluster.GetType(), cluster.GetClusterType(), cluster) } clusters := &v3aggregateclusterpb.ClusterConfig{}