Skip to content

Commit

Permalink
Add auth header only when env var is set (influxdata#6469)
Browse files Browse the repository at this point in the history
  • Loading branch information
rawkode authored and Mathieu Lecarme committed Apr 17, 2020
1 parent afd74a0 commit 6ca5805
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,14 @@ func loadConfig(config string) ([]byte, error) {
}

func fetchConfig(u *url.URL) ([]byte, error) {
v := os.Getenv("INFLUX_TOKEN")

req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
req.Header.Add("Authorization", "Token "+v)

if v, exists := os.LookupEnv("INFLUX_TOKEN"); exists {
req.Header.Add("Authorization", "Token "+v)
}
req.Header.Add("Accept", "application/toml")
resp, err := http.DefaultClient.Do(req)
if err != nil {
Expand Down

0 comments on commit 6ca5805

Please sign in to comment.