mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +00:00
lib/promscrape: allow explicitly setting empty token via token: ""
in consul_sd_config
This commit is contained in:
parent
fd739808f3
commit
054457d1f4
2 changed files with 6 additions and 6 deletions
|
@ -85,9 +85,9 @@ func newAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
|||
return cfg, nil
|
||||
}
|
||||
|
||||
func getToken(token string) (string, error) {
|
||||
if token != "" {
|
||||
return token, nil
|
||||
func getToken(token *string) (string, error) {
|
||||
if token != nil {
|
||||
return *token, nil
|
||||
}
|
||||
if tokenFile := os.Getenv("CONSUL_HTTP_TOKEN_FILE"); tokenFile != "" {
|
||||
data, err := ioutil.ReadFile(tokenFile)
|
||||
|
@ -96,9 +96,9 @@ func getToken(token string) (string, error) {
|
|||
}
|
||||
return string(data), nil
|
||||
}
|
||||
token = os.Getenv("CONSUL_HTTP_TOKEN")
|
||||
t := os.Getenv("CONSUL_HTTP_TOKEN")
|
||||
// Allow empty token - it shouls work if authorization is disabled in Consul
|
||||
return token, nil
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func getDatacenter(client *discoveryutils.Client, dc string) (string, error) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config
|
||||
type SDConfig struct {
|
||||
Server string `yaml:"server"`
|
||||
Token string `yaml:"token"`
|
||||
Token *string `yaml:"token"`
|
||||
Datacenter string `yaml:"datacenter"`
|
||||
Scheme string `yaml:"scheme"`
|
||||
Username string `yaml:"username"`
|
||||
|
|
Loading…
Reference in a new issue