From b4a0edf5ba2adf474d60f2f609fd5536d661ae55 Mon Sep 17 00:00:00 2001 From: Sergei Smolianinov Date: Mon, 23 Oct 2017 22:31:27 +0300 Subject: [PATCH] Fix ACL token usage in consul input plugin (#3376) --- plugins/inputs/consul/consul.go | 4 ++++ plugins/inputs/consul/consul_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/consul/consul.go b/plugins/inputs/consul/consul.go index 0eaa25604..45612a928 100644 --- a/plugins/inputs/consul/consul.go +++ b/plugins/inputs/consul/consul.go @@ -69,6 +69,10 @@ func (c *Consul) createAPIClient() (*api.Client, error) { config.Datacenter = c.Datacentre } + if c.Token != "" { + config.Token = c.Token + } + if c.Username != "" { config.HttpAuth = &api.HttpBasicAuth{ Username: c.Username, diff --git a/plugins/inputs/consul/consul_test.go b/plugins/inputs/consul/consul_test.go index d0595508d..bbb43d066 100644 --- a/plugins/inputs/consul/consul_test.go +++ b/plugins/inputs/consul/consul_test.go @@ -20,7 +20,7 @@ var sampleChecks = []*api.HealthCheck{ }, } -func TestGatherHealtCheck(t *testing.T) { +func TestGatherHealthCheck(t *testing.T) { expectedFields := map[string]interface{}{ "check_name": "foo.health", "status": "passing",