in otelcollector/prometheusreceiver/targetallocator/config.go [137:197]
func configureSDHTTPClientConfigFromTA(httpSD *promHTTP.SDConfig, allocConf *Config) error {
httpSD.HTTPClientConfig.FollowRedirects = false
httpSD.HTTPClientConfig.TLSConfig = commonconfig.TLSConfig{
InsecureSkipVerify: allocConf.TLSSetting.InsecureSkipVerify,
ServerName: allocConf.TLSSetting.ServerName,
CAFile: allocConf.TLSSetting.CAFile,
CertFile: allocConf.TLSSetting.CertFile,
KeyFile: allocConf.TLSSetting.KeyFile,
}
if allocConf.TLSSetting.CAPem != "" {
decodedCA, err := base64.StdEncoding.DecodeString(string(allocConf.TLSSetting.CAPem))
if err != nil {
return fmt.Errorf("failed to decode CA: %w", err)
}
httpSD.HTTPClientConfig.TLSConfig.CA = string(decodedCA)
}
if allocConf.TLSSetting.CertPem != "" {
decodedCert, err := base64.StdEncoding.DecodeString(string(allocConf.TLSSetting.CertPem))
if err != nil {
return fmt.Errorf("failed to decode Cert: %w", err)
}
httpSD.HTTPClientConfig.TLSConfig.Cert = string(decodedCert)
}
if allocConf.TLSSetting.KeyPem != "" {
decodedKey, err := base64.StdEncoding.DecodeString(string(allocConf.TLSSetting.KeyPem))
if err != nil {
return fmt.Errorf("failed to decode Key: %w", err)
}
httpSD.HTTPClientConfig.TLSConfig.Key = commonconfig.Secret(decodedKey)
}
if allocConf.TLSSetting.MinVersion != "" {
minVersion, err := convertTLSVersion(allocConf.TLSSetting.MinVersion)
if err != nil {
return err
}
httpSD.HTTPClientConfig.TLSConfig.MinVersion = minVersion
}
if allocConf.TLSSetting.MaxVersion != "" {
maxVersion, err := convertTLSVersion(allocConf.TLSSetting.MaxVersion)
if err != nil {
return err
}
httpSD.HTTPClientConfig.TLSConfig.MaxVersion = maxVersion
}
if allocConf.ProxyURL != "" {
proxyURL, err := url.Parse(allocConf.ProxyURL)
if err != nil {
return err
}
httpSD.HTTPClientConfig.ProxyURL = commonconfig.URL{URL: proxyURL}
}
return nil
}