Skip to content

Commit

Permalink
update prometheus common
Browse files Browse the repository at this point in the history
Signed-off-by: alanprot <[email protected]>
  • Loading branch information
alanprot committed Jun 10, 2024
1 parent 89aabf2 commit a1e9a67
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ require (
github.com/prometheus/alertmanager v0.27.0
github.com/prometheus/client_golang v1.19.1
github.com/prometheus/client_model v0.6.1
github.com/prometheus/common v0.54.1-0.20240607150646-318309999517
github.com/prometheus/common v0.54.1-0.20240608102853-1c9da3533702
github.com/prometheus/exporter-toolkit v0.11.0
// Prometheus maps version 2.x.y to tags v0.x.y.
github.com/prometheus/prometheus v0.52.2-0.20240606174736-edd558884b24
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2121,8 +2121,8 @@ github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/common v0.54.1-0.20240607150646-318309999517 h1:Zsbmc1YVvxcOtxQi3VwFw5LCmTWVSg/YQHA0J86td4I=
github.com/prometheus/common v0.54.1-0.20240607150646-318309999517/go.mod h1:1Yn/UzXoahbVLk1sn6wsGiSiemz3XQejcaz9FIA1r+I=
github.com/prometheus/common v0.54.1-0.20240608102853-1c9da3533702 h1:lL+9gURs5kVint1cswUnvAvcoOYCVtffz0Bq6vk/yX4=
github.com/prometheus/common v0.54.1-0.20240608102853-1c9da3533702/go.mod h1:1Yn/UzXoahbVLk1sn6wsGiSiemz3XQejcaz9FIA1r+I=
github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4=
github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI=
github.com/prometheus/exporter-toolkit v0.8.2/go.mod h1:00shzmJL7KxcsabLWcONwpyNEuWhREOnFqZW7vadFS0=
Expand Down
20 changes: 12 additions & 8 deletions pkg/clientconfig/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,25 @@ func NewRoundTripperFromConfig(cfg config_util.HTTPClientConfig, transportConfig
// If an authorization_credentials is provided, create a round tripper that will set the
// Authorization header correctly on each request.
if cfg.Authorization != nil && len(cfg.Authorization.Credentials) > 0 {
rt = config_util.NewAuthorizationCredentialsRoundTripper(cfg.Authorization.Type, cfg.Authorization.Credentials, rt)
rt = config_util.NewAuthorizationCredentialsRoundTripper(cfg.Authorization.Type, config_util.NewInlineSecret(string(cfg.Authorization.Credentials)), rt)
} else if cfg.Authorization != nil && len(cfg.Authorization.CredentialsFile) > 0 {
rt = config_util.NewAuthorizationCredentialsFileRoundTripper(cfg.Authorization.Type, cfg.Authorization.CredentialsFile, rt)
rt = config_util.NewAuthorizationCredentialsRoundTripper(cfg.Authorization.Type, config_util.NewFileSecret(cfg.Authorization.CredentialsFile), rt)
}
// Backwards compatibility, be nice with importers who would not have
// called Validate().
if len(cfg.BearerToken) > 0 {
rt = config_util.NewAuthorizationCredentialsRoundTripper("Bearer", cfg.BearerToken, rt)
rt = config_util.NewAuthorizationCredentialsRoundTripper("Bearer", config_util.NewInlineSecret(string(cfg.BearerToken)), rt)
} else if len(cfg.BearerTokenFile) > 0 {
rt = config_util.NewAuthorizationCredentialsFileRoundTripper("Bearer", cfg.BearerTokenFile, rt)
rt = config_util.NewAuthorizationCredentialsRoundTripper("Bearer", config_util.NewInlineSecret(cfg.BearerTokenFile), rt)
}

if cfg.BasicAuth != nil {
// TODO(yeya24): expose UsernameFile as a config.
rt = config_util.NewBasicAuthRoundTripper(cfg.BasicAuth.Username, cfg.BasicAuth.Password, "", cfg.BasicAuth.PasswordFile, rt)
if len(cfg.BasicAuth.PasswordFile) >= 0 {
rt = config_util.NewBasicAuthRoundTripper(config_util.NewInlineSecret(cfg.BasicAuth.Username), config_util.NewInlineSecret(cfg.BasicAuth.PasswordFile), rt)
} else if len(cfg.BasicAuth.Password) >= 0 {
rt = config_util.NewBasicAuthRoundTripper(config_util.NewInlineSecret(cfg.BasicAuth.Username), config_util.NewInlineSecret(string(cfg.BasicAuth.Password)), rt)
}
}
// Return a new configured RoundTripper.
return rt, nil
Expand All @@ -193,9 +197,9 @@ func NewRoundTripperFromConfig(cfg config_util.HTTPClientConfig, transportConfig
}

return config_util.NewTLSRoundTripper(tlsConfig, config_util.TLSRoundTripperSettings{
CAFile: cfg.TLSConfig.CAFile,
CertFile: cfg.TLSConfig.CertFile,
KeyFile: cfg.TLSConfig.KeyFile,
CA: config_util.NewFileSecret(cfg.TLSConfig.CAFile),
Cert: config_util.NewFileSecret(cfg.TLSConfig.CertFile),
Key: config_util.NewFileSecret(cfg.TLSConfig.KeyFile),
}, newRT)
}

Expand Down

0 comments on commit a1e9a67

Please sign in to comment.