From 3a1cdac25e7aa915a6cdd16bceee7bafbaefb68f Mon Sep 17 00:00:00 2001 From: Lang Martin Date: Thu, 2 Jul 2020 10:04:22 -0400 Subject: [PATCH] command/debug: use the correct env vars for Consul token (#8332) --- command/debug.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/command/debug.go b/command/debug.go index 063b5de33..26ae5ef0d 100644 --- a/command/debug.go +++ b/command/debug.go @@ -78,7 +78,8 @@ Debug Options: in the current directory. -consul-token - Token used to query Consul. Defaults to CONSUL_TOKEN + Token used to query Consul. Defaults to CONSUL_HTTP_TOKEN or the contents of + CONSUL_HTTP_TOKEN_FILE -vault-token Token used to query Vault. Defaults to VAULT_TOKEN @@ -514,7 +515,19 @@ func (c *DebugCommand) collectConsul(dir, consul string) error { token := c.consulToken if token == "" { - os.Getenv("CONSUL_TOKEN") + token = os.Getenv("CONSUL_HTTP_TOKEN") + } + if token == "" { + file := os.Getenv("CONSUL_HTTP_TOKEN_FILE") + if file != "" { + fh, err := os.Open(file) + if err == nil { + bs, err := ioutil.ReadAll(fh) + if err == nil { + token = strings.TrimSpace(string(bs)) + } + } + } } client := http.Client{