in pkg/config/http_client.go [64:107]
func (hc *HTTPClientConfig) NewRestClientConfig(client *kubernetes.Clientset, def *restclient.Config) (*restclient.Config, error) {
// defensive copy
def = restclient.CopyConfig(def)
if hc == nil {
return def, nil
}
config := restclient.Config{}
if hc.Host == "" {
return nil, errors.New("host is a mandatory field")
}
config.Host = hc.Host
if hc.Timeout != nil {
config.Timeout = hc.Timeout.Duration
}
config.APIPath = def.APIPath
// TLS fields
if hc.TLSClientConfig == nil {
// Reuse default values
config.TLSClientConfig = def.TLSClientConfig
} else {
config.TLSClientConfig.Insecure = hc.TLSClientConfig.Insecure
config.TLSClientConfig.CAFile = hc.TLSClientConfig.CAFile
}
// Authentication fields
if hc.AuthenticationConfig == nil {
config.TLSClientConfig.CertData = def.CertData
config.TLSClientConfig.KeyData = def.KeyData
config.BearerTokenFile = def.BearerTokenFile
} else {
config.TLSClientConfig.CertFile = hc.AuthenticationConfig.CertFile
config.TLSClientConfig.KeyFile = hc.AuthenticationConfig.KeyFile
config.BearerTokenFile = hc.AuthenticationConfig.BearerTokenFile
}
config.UserAgent = "Elasticsearch Metrics Adapter/0.0.1"
// Inherit provider config, mostly use in dev mode
config.AuthProvider = def.AuthProvider
config.AuthConfigPersister = def.AuthConfigPersister
config.ExecProvider = def.ExecProvider
return &config, nil
}