@@ -34,7 +34,6 @@ import (
3434 "google.golang.org/grpc/credentials/tls/certprovider"
3535 "google.golang.org/grpc/internal"
3636 "google.golang.org/grpc/internal/envconfig"
37- "google.golang.org/grpc/internal/pretty"
3837 "google.golang.org/grpc/xds/bootstrap"
3938 "google.golang.org/protobuf/proto"
4039 "google.golang.org/protobuf/types/known/structpb"
@@ -213,6 +212,9 @@ func (sc *ServerConfig) Equal(other *ServerConfig) bool {
213212// content. It doesn't cover NodeProto because NodeProto isn't used by
214213// federation.
215214func (sc * ServerConfig ) String () string {
215+ if len (sc .serverFeatures ) == 0 {
216+ return fmt .Sprintf ("%s-%s" , sc .serverURI , sc .selectedCreds .String ())
217+ }
216218 features := strings .Join (sc .serverFeatures , "-" )
217219 return strings .Join ([]string {sc .serverURI , sc .selectedCreds .String (), features }, "-" )
218220}
@@ -418,6 +420,12 @@ func (c *Config) Equal(other *Config) bool {
418420 return true
419421}
420422
423+ // String returns a string representation of the Config.
424+ func (c * Config ) String () string {
425+ s , _ := c .MarshalJSON ()
426+ return string (s )
427+ }
428+
421429// The following fields correspond 1:1 with the JSON schema for Config.
422430type configJSON struct {
423431 XDSServers []* ServerConfig `json:"xds_servers,omitempty"`
@@ -438,7 +446,7 @@ func (c *Config) MarshalJSON() ([]byte, error) {
438446 Authorities : c .authorities ,
439447 Node : c .node ,
440448 }
441- return json .Marshal (config )
449+ return json .MarshalIndent (config , " " , " " )
442450}
443451
444452// UnmarshalJSON takes the json data (the complete bootstrap configuration) and
@@ -566,9 +574,7 @@ func newConfigFromContents(data []byte) (*Config, error) {
566574 }
567575
568576 if logger .V (2 ) {
569- logger .Infof ("Bootstrap config for creating xds-client: %v" , pretty .ToJSON (config ))
570- } else {
571- logger .Infof ("Bootstrap config for creating xds-client: %+v" , config )
577+ logger .Infof ("Bootstrap config for creating xds-client: %s" , config )
572578 }
573579 return config , nil
574580}
@@ -632,7 +638,7 @@ func NewContentsForTesting(opts ConfigOptionsForTesting) ([]byte, error) {
632638 Authorities : authorities ,
633639 Node : node {ID : opts .NodeID },
634640 }
635- contents , err := json .Marshal (cfgJSON )
641+ contents , err := json .MarshalIndent (cfgJSON , " " , " " )
636642 if err != nil {
637643 return nil , fmt .Errorf ("failed to marshal bootstrap configuration for provided options %+v: %v" , opts , err )
638644 }
0 commit comments