From e6902166e0efeb187b4f974e95118e5defabeb88 Mon Sep 17 00:00:00 2001 From: arunkumar-m Date: Wed, 21 Dec 2016 21:51:15 -0800 Subject: [PATCH] KV command does not pass CONSUL_HTTP_TOKEN (#2566) --- command/kv_delete.go | 4 +++- command/kv_get.go | 4 +++- command/kv_put.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/command/kv_delete.go b/command/kv_delete.go index 85b30b4c8f0e..46f1532411b6 100644 --- a/command/kv_delete.go +++ b/command/kv_delete.go @@ -111,7 +111,9 @@ func (c *KVDeleteCommand) Run(args []string) int { // Create and test the HTTP client conf := api.DefaultConfig() conf.Address = *httpAddr - conf.Token = *token + if *token != "" { + conf.Token = *token + } client, err := api.NewClient(conf) if err != nil { c.Ui.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) diff --git a/command/kv_get.go b/command/kv_get.go index c49d983b4801..6b255f4b4ed3 100644 --- a/command/kv_get.go +++ b/command/kv_get.go @@ -126,7 +126,9 @@ func (c *KVGetCommand) Run(args []string) int { // Create and test the HTTP client conf := api.DefaultConfig() conf.Address = *httpAddr - conf.Token = *token + if *token != "" { + conf.Token = *token + } client, err := api.NewClient(conf) if err != nil { c.Ui.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) diff --git a/command/kv_put.go b/command/kv_put.go index c03cf4f49bf8..6f9f7624f563 100644 --- a/command/kv_put.go +++ b/command/kv_put.go @@ -142,7 +142,9 @@ func (c *KVPutCommand) Run(args []string) int { // Create and test the HTTP client conf := api.DefaultConfig() conf.Address = *httpAddr - conf.Token = *token + if *token != "" { + conf.Token = *token + } client, err := api.NewClient(conf) if err != nil { c.Ui.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err))