@@ -31,7 +31,9 @@ import (
3131 "google.golang.org/grpc/internal/grpcsync"
3232 "google.golang.org/grpc/internal/pretty"
3333 iresolver "google.golang.org/grpc/internal/resolver"
34+ "google.golang.org/grpc/internal/wrr"
3435 "google.golang.org/grpc/resolver"
36+ rinternal "google.golang.org/grpc/xds/internal/resolver/internal"
3537 "google.golang.org/grpc/xds/internal/xdsclient"
3638 "google.golang.org/grpc/xds/internal/xdsclient/bootstrap"
3739 "google.golang.org/grpc/xds/internal/xdsclient/xdsresource"
@@ -54,12 +56,12 @@ func newBuilderForTesting(config []byte) (resolver.Builder, error) {
5456 }, nil
5557}
5658
57- // For overriding in unittests.
58- var newXDSClient = func () (xdsclient.XDSClient , func (), error ) { return xdsclient .New () }
59-
6059func init () {
6160 resolver .Register (& xdsResolverBuilder {})
6261 internal .NewXDSResolverWithConfigForTesting = newBuilderForTesting
62+
63+ rinternal .NewWRR = wrr .NewRandom
64+ rinternal .NewXDSClient = xdsclient .New
6365}
6466
6567type xdsResolverBuilder struct {
@@ -86,7 +88,7 @@ func (b *xdsResolverBuilder) Build(target resolver.Target, cc resolver.ClientCon
8688 r .logger = prefixLogger (r )
8789 r .logger .Infof ("Creating resolver for target: %+v" , target )
8890
89- newXDSClient := newXDSClient
91+ newXDSClient := rinternal . NewXDSClient .( func () (xdsclient. XDSClient , func (), error ))
9092 if b .newXDSClient != nil {
9193 newXDSClient = b .newXDSClient
9294 }
@@ -115,7 +117,7 @@ func (b *xdsResolverBuilder) Build(target resolver.Target, cc resolver.ClientCon
115117 }
116118 if xc , ok := creds .(interface { UsesXDS () bool }); ok && xc .UsesXDS () {
117119 if len (bootstrapConfig .CertProviderConfigs ) == 0 {
118- return nil , errors . New ("xds: xdsCreds specified but certificate_providers config missing in bootstrap file" )
120+ return nil , fmt . Errorf ("xds: use of xDS credentials is specified, but certificate_providers config missing in bootstrap file" )
119121 }
120122 }
121123
0 commit comments