Skip to content

Commit 63b00bd

Browse files
committed
move the check for XDSBootstrapCallCredsEnabled when unmarshalling bootstrap config
1 parent 9cb3bf4 commit 63b00bd

2 files changed

Lines changed: 20 additions & 22 deletions

File tree

internal/xds/bootstrap/bootstrap.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -349,25 +349,27 @@ func (sc *ServerConfig) UnmarshalJSON(data []byte) error {
349349
break
350350
}
351351

352-
// Process call credentials - unlike channel creds, we use ALL supported
353-
// types. Also, call credentials are optional as per gRFC A97.
354-
for _, callCredConfig := range server.CallCreds {
355-
c := bootstrap.GetCallCredentials(callCredConfig.Type)
356-
if c == nil {
357-
// Skip unsupported call credential types (don't fail bootstrap).
358-
continue
359-
}
360-
callCred, cancel, err := c.Build(callCredConfig.Config)
361-
if err != nil {
362-
// Call credential validation failed - this should fail bootstrap.
363-
return fmt.Errorf("failed to build call credentials from bootstrap for %q: %v", callCredConfig.Type, err)
364-
}
365-
if callCred == nil {
366-
continue
352+
if envconfig.XDSBootstrapCallCredsEnabled {
353+
// Process call credentials - unlike channel creds, we use ALL supported
354+
// types. Also, call credentials are optional as per gRFC A97.
355+
for _, callCredConfig := range server.CallCreds {
356+
c := bootstrap.GetCallCredentials(callCredConfig.Type)
357+
if c == nil {
358+
// Skip unsupported call credential types (don't fail bootstrap).
359+
continue
360+
}
361+
callCred, cancel, err := c.Build(callCredConfig.Config)
362+
if err != nil {
363+
// Call credential validation failed - this should fail bootstrap.
364+
return fmt.Errorf("failed to build call credentials from bootstrap for %q: %v", callCredConfig.Type, err)
365+
}
366+
if callCred == nil {
367+
continue
368+
}
369+
sc.selectedCallCreds = append(sc.selectedCallCreds, callCred)
370+
sc.extraDialOptions = append(sc.extraDialOptions, grpc.WithPerRPCCredentials(callCred))
371+
sc.cleanups = append(sc.cleanups, cancel)
367372
}
368-
sc.selectedCallCreds = append(sc.selectedCallCreds, callCred)
369-
sc.extraDialOptions = append(sc.extraDialOptions, grpc.WithPerRPCCredentials(callCred))
370-
sc.cleanups = append(sc.cleanups, cancel)
371373
}
372374

373375
if sc.serverURI == "" {

xds/bootstrap/bootstrap.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"encoding/json"
3030

3131
"google.golang.org/grpc/credentials"
32-
"google.golang.org/grpc/internal/envconfig"
3332
)
3433

3534
// channelCredsRegistry is a map from credential type name to ChannelCredential builder.
@@ -91,9 +90,6 @@ func RegisterCallCredentials(c CallCredentials) {
9190
// GetCallCredentials returns the credentials associated with a given name.
9291
// If no credentials are registered with the name, nil will be returned.
9392
func GetCallCredentials(name string) CallCredentials {
94-
if name == "jwt_token_file" && !envconfig.XDSBootstrapCallCredsEnabled {
95-
return nil
96-
}
9793
if c, ok := callCredsRegistry[name]; ok {
9894
return c
9995
}

0 commit comments

Comments
 (0)