You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// GetConfiguration returns the bootstrap configuration initialized by reading
514
+
// the bootstrap file found at ${GRPC_XDS_BOOTSTRAP} or bootstrap contents
515
+
// specified at ${GRPC_XDS_BOOTSTRAP_CONFIG}. If both env vars are set, the
516
+
// former is preferred.
517
+
//
518
+
// If none of the env vars are set, this function returns the fallback
519
+
// configuration if it is not nil. Else, it returns an error.
520
+
//
521
+
// This function tries to process as much of the bootstrap file as possible (in
522
+
// the presence of the errors) and may return a Config object with certain
523
+
// fields left unspecified, in which case the caller should use some sane
524
+
// defaults.
525
+
funcGetConfiguration() (*Config, error) {
516
526
fName:=envconfig.XDSBootstrapFileName
517
527
fContent:=envconfig.XDSBootstrapFileContent
518
528
519
529
iffName!="" {
520
530
iflogger.V(2) {
521
-
logger.Infof("Using bootstrap file with name %q", fName)
531
+
logger.Infof("Using bootstrap file with name %q from GRPC_XDS_BOOTSTRAP environment variable", fName)
522
532
}
523
-
returnbootstrapFileReadFunc(fName)
533
+
cfg, err:=bootstrapFileReadFunc(fName)
534
+
iferr!=nil {
535
+
returnnil, fmt.Errorf("xds: failed to read bootstrap config from file %q: %v", fName, err)
536
+
}
537
+
returnnewConfigFromContents(cfg)
524
538
}
525
539
526
540
iffContent!="" {
527
-
return []byte(fContent), nil
541
+
iflogger.V(2) {
542
+
logger.Infof("Using bootstrap contents from GRPC_XDS_BOOTSTRAP_CONFIG environment variable")
543
+
}
544
+
returnnewConfigFromContents([]byte(fContent))
528
545
}
529
546
530
-
returnnil, fmt.Errorf("none of the bootstrap environment variables (%q or %q) defined", envconfig.XDSBootstrapFileNameEnv, envconfig.XDSBootstrapFileContentEnv)
531
-
}
532
-
533
-
// NewConfig returns a new instance of Config initialized by reading the
534
-
// bootstrap file found at ${GRPC_XDS_BOOTSTRAP} or bootstrap contents specified
535
-
// at ${GRPC_XDS_BOOTSTRAP_CONFIG}. If both env vars are set, the former is
536
-
// preferred.
537
-
//
538
-
// We support a credential registration mechanism and only credentials
539
-
// registered through that mechanism will be accepted here. See package
540
-
// `xds/bootstrap` for details.
541
-
//
542
-
// This function tries to process as much of the bootstrap file as possible (in
543
-
// the presence of the errors) and may return a Config object with certain
544
-
// fields left unspecified, in which case the caller should use some sane
545
-
// defaults.
546
-
funcNewConfig() (*Config, error) {
547
-
// Examples of the bootstrap json can be found in the generator tests
returnnil, fmt.Errorf("bootstrap environment variables (%q or %q) not defined, and no fallback config set", envconfig.XDSBootstrapFileNameEnv, envconfig.XDSBootstrapFileContentEnv)
0 commit comments