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
(cherry picked from commit 367dee7)
  • Loading branch information
rawkode authored and danielnelson committed Sep 30, 2019
1 parent 22884fd commit 7fa765c
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 @@ -836,13 +836,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 7fa765c

Please sign in to comment.