Skip to content

Commit 7ac3bd6

Browse files
committed
fix review comments
1 parent 4ac57e9 commit 7ac3bd6

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

Diff for: balancer/grpclb/grpclb_remote_balancer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func (lb *lbBalancer) dialRemoteLB(remoteLBName string) {
272272
dopts = append(dopts, grpc.WithInsecure())
273273
}
274274
} else if bundle := lb.grpclbClientConnCreds; bundle != nil {
275-
dopts = append(dopts, grpc.WithCreds(bundle))
275+
dopts = append(dopts, grpc.WithCredentialsBundle(bundle))
276276
} else {
277277
dopts = append(dopts, grpc.WithInsecure())
278278
}

Diff for: credentials/google/google.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ func (c *creds) SwitchMode(mode string) (credentials.Bundle, error) {
8686
newCreds.transportCreds = credentials.NewTLS(nil)
8787
case internal.CredsBundleModeALTS, internal.CredsBundleModeGRPCLB:
8888
if !vmOnGCP {
89-
return nil, errors.New("ALTS, as part of google default credentials, is only supported on GCP")
89+
return nil, errors.New("google default creds: ALTS, as part of google default credentials, is only supported on GCP")
9090
}
91+
// Only the clients can use google default credentials, so we only need
92+
// to create new ALTS client creds here.
9193
newCreds.transportCreds = alts.NewClientCreds(alts.DefaultClientOptions())
9294
default:
93-
return nil, fmt.Errorf("unsupported mode: %v", mode)
95+
return nil, fmt.Errorf("google default creds: unsupported mode: %v", mode)
9496
}
9597

9698
// Create per RPC credentials.

Diff for: dialoptions.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,12 @@ func WithPerRPCCredentials(creds credentials.PerRPCCredentials) DialOption {
302302
})
303303
}
304304

305-
// WithCreds returns a DialOption to set a credentials bundle for the
306-
// ClientConn.WithCreds. This should not be used together with
305+
// WithCredentialsBundle returns a DialOption to set a credentials bundle for
306+
// the ClientConn.WithCreds. This should not be used together with
307307
// WithTransportCredentials.
308308
//
309309
// This API is experimental.
310-
func WithCreds(b credentials.Bundle) DialOption {
310+
func WithCredentialsBundle(b credentials.Bundle) DialOption {
311311
return newFuncDialOption(func(o *dialOptions) {
312312
o.copts.CredsBundle = b
313313
})

Diff for: internal/transport/http2_client.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,21 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr TargetInfo, opts Conne
169169
isSecure bool
170170
authInfo credentials.AuthInfo
171171
)
172-
var creds credentials.TransportCredentials
172+
var transportCreds credentials.TransportCredentials
173173
perRPCCreds := opts.PerRPCCredentials
174174

175175
if b := opts.CredsBundle; b != nil {
176-
creds = b.TransportCredentials()
176+
transportCreds = b.TransportCredentials()
177177
if t := b.PerRPCCredentials(); t != nil {
178178
perRPCCreds = append(perRPCCreds, t)
179179
}
180180
}
181-
if creds == nil {
182-
creds = opts.TransportCredentials
181+
if transportCreds == nil {
182+
transportCreds = opts.TransportCredentials
183183
}
184-
if creds != nil {
184+
if transportCreds != nil {
185185
scheme = "https"
186-
conn, authInfo, err = creds.ClientHandshake(connectCtx, addr.Authority, conn)
186+
conn, authInfo, err = transportCreds.ClientHandshake(connectCtx, addr.Authority, conn)
187187
if err != nil {
188188
return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed: %v", err)
189189
}

Diff for: interop/client/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func main() {
107107
altsTC := alts.NewClientCreds(altsOpts)
108108
opts = append(opts, grpc.WithTransportCredentials(altsTC))
109109
} else if *useGoogleDefaultCreds {
110-
opts = append(opts, grpc.WithCreds(google.NewDefaultCredentials()))
110+
opts = append(opts, grpc.WithCredentialsBundle(google.NewDefaultCredentials()))
111111
} else {
112112
opts = append(opts, grpc.WithInsecure())
113113
}

Diff for: test/creds_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestCredsBundleBoth(t *testing.T) {
7070
te := newTest(t, env{name: "creds-bundle", network: "tcp", balancer: "v1", security: "empty"})
7171
te.tapHandle = authHandle
7272
te.customDialOptions = []grpc.DialOption{
73-
grpc.WithCreds(&testCredsBundle{t: t}),
73+
grpc.WithCredentialsBundle(&testCredsBundle{t: t}),
7474
}
7575
creds, err := credentials.NewServerTLSFromFile(testdata.Path("server1.pem"), testdata.Path("server1.key"))
7676
if err != nil {
@@ -93,7 +93,7 @@ func TestCredsBundleTransportCredentials(t *testing.T) {
9393
defer leakcheck.Check(t)
9494
te := newTest(t, env{name: "creds-bundle", network: "tcp", balancer: "v1", security: "empty"})
9595
te.customDialOptions = []grpc.DialOption{
96-
grpc.WithCreds(&testCredsBundle{t: t, mode: bundleTLSOnly}),
96+
grpc.WithCredentialsBundle(&testCredsBundle{t: t, mode: bundleTLSOnly}),
9797
}
9898
creds, err := credentials.NewServerTLSFromFile(testdata.Path("server1.pem"), testdata.Path("server1.key"))
9999
if err != nil {
@@ -117,7 +117,7 @@ func TestCredsBundlePerRPCCredentials(t *testing.T) {
117117
te := newTest(t, env{name: "creds-bundle", network: "tcp", balancer: "v1", security: "empty"})
118118
te.tapHandle = authHandle
119119
te.customDialOptions = []grpc.DialOption{
120-
grpc.WithCreds(&testCredsBundle{t: t, mode: bundlePerRPCOnly}),
120+
grpc.WithCredentialsBundle(&testCredsBundle{t: t, mode: bundlePerRPCOnly}),
121121
}
122122
te.startServer(&testServer{})
123123
defer te.tearDown()

0 commit comments

Comments
 (0)