func CharmHubConfig(logger Logger, options ...Option) (Config, error) {
	opts := newOptions()
	for _, option := range options {
		option(opts)
	}

	if logger == nil {
		return Config{}, errors.NotValidf("nil logger")
	}

	// By default we want to specify a default user-agent here. In the future
	// we should ensure this probably contains model UUID and cloud.
	headers := make(http.Header)
	headers.Set(userAgentKey, userAgentValue)

	// Additionally apply any metadata headers to the headers so we can send
	// every time we make a request.
	m := opts.metadataHeaders
	keys := make([]string, 0, len(m))
	for k := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for _, k := range keys {
		headers.Add(MetadataHeader, k+"="+m[k])
	}

	chLogger := logger.ChildWithLabels("client", corelogger.CHARMHUB)
	return Config{
		URL:       *opts.url,
		Version:   CharmHubServerVersion,
		Entity:    CharmHubServerEntity,
		Headers:   headers,
		Transport: opts.transportFunc(chLogger.ChildWithLabels("transport", corelogger.HTTP)),
		Logger:    chLogger,
	}, nil
}
// CharmHubConfig defines a charmHub client configuration for targeting the
// charmhub API.
CharmHubConfig defines a charmHub client configuration for targeting the
charmhub API.
// CharmHubConfig defines a charmHub client configuration for targeting the // charmhub API .
func CharmHubConfig(logger Logger, options ...Option) (Config, error) {
	opts := newOptions()
	for _, option := range options {
		option(opts)
	}
	if logger == nil {
		return Config{}, errors.NotValidf("nil logger")
	}
	headers := make(http.Header)
	headers.Set(userAgentKey, userAgentValue)
	m := opts.metadataHeaders
	keys := make([]string, 0, len(m))
	for k := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for _, k := range keys {
		headers.Add(MetadataHeader, k+"="+m[k])
	}
	chLogger := logger.ChildWithLabels("client", corelogger.CHARMHUB)
	return Config{
		URL:       *opts.url,
		Version:   CharmHubServerVersion,
		Entity:    CharmHubServerEntity,
		Headers:   headers,
		Transport: opts.transportFunc(chLogger.ChildWithLabels("transport", corelogger.HTTP)),
		Logger:    chLogger,
	}, nil
}
func CharmHubConfig ( logger Logger , options ... Option ) ( Config , error ) { opts := newOptions ( ) for _ , option := range options { option ( opts ) } if logger == nil { return Config { } , errors . NotValidf ( " " ) } headers := make ( http . Header ) headers . Set ( userAgentKey , userAgentValue ) m := opts . metadataHeaders keys := make ( [ ] string , 0 , len ( m ) ) for k := range m { keys = append ( keys , k ) } sort . Strings ( keys ) for _ , k := range keys { headers . Add ( MetadataHeader , k + " " + m [ k ] ) } chLogger := logger . ChildWithLabels ( " " , corelogger . CHARMHUB ) return Config { URL : * opts . url , Version : CharmHubServerVersion , Entity : CharmHubServerEntity , Headers : headers , Transport : opts . transportFunc ( chLogger . ChildWithLabels ( " " , corelogger . HTTP ) ) , Logger : chLogger , } , nil }
CharmHubConfig defines a charmHub client configuration for targeting the
charmhub API.
CharmHubConfig defines a charmHub client configuration for targeting the charmhub API .
// By default we want to specify a default user-agent here. In the future // we should ensure this probably contains model UUID and cloud. // Additionally apply any metadata headers to the headers so we can send // every time we make a request.