Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
Added fallback to "anonymous" if Consul Token is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Mar 29, 2019
1 parent 0a4edb5 commit 5d427f0
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Travis](https://img.shields.io/travis/sbueringer/grafana-consul-datasource.svg)](https://travis-ci.org/sbueringer/grafana-consul-datasource)[![Codecov](https://img.shields.io/codecov/c/github/sbueringer/grafana-consul-datasource.svg)](https://codecov.io/gh/sbueringer/grafana-consul-datasource)[![CodeFactor](https://www.codefactor.io/repository/github/sbueringer/grafana-consul-datasource/badge)](https://www.codefactor.io/repository/github/sbueringer/grafana-consul-datasource)[![GoReportCard](https://goreportcard.com/badge/github.com/sbueringer/grafana-consul-datasource?style=plastic)](https://goreportcard.com/report/github.com/sbueringer/grafana-consul-datasource)[![GitHub release](https://img.shields.io/github/release/sbueringer/grafana-consul-datasource.svg)](https://github.com/sbueringer/grafana-consul-datasource/releases)

[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sbueringer/consul-datasource/issues)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sbueringer/grafana-consul-datasource/issues)

This datasource lets you integrate key value data from Consul in Grafana dashboards.

Expand Down
3 changes: 2 additions & 1 deletion datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ type query struct {
func newConsulFromReq(req *datasource.DatasourceRequest) (*api.Client, string, error) {
consulToken := req.Datasource.DecryptedSecureJsonData["consulToken"]
if consulToken == "" {
return nil, "", fmt.Errorf("unable to get consulToken")
// see https://www.consul.io/docs/acl/acl-system.html#acl-tokens
consulToken = "anonymous"
}

var jsonData map[string]interface{}
Expand Down
2 changes: 1 addition & 1 deletion dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Travis](https://img.shields.io/travis/sbueringer/grafana-consul-datasource.svg)](https://travis-ci.org/sbueringer/grafana-consul-datasource)[![Codecov](https://img.shields.io/codecov/c/github/sbueringer/grafana-consul-datasource.svg)](https://codecov.io/gh/sbueringer/grafana-consul-datasource)[![CodeFactor](https://www.codefactor.io/repository/github/sbueringer/grafana-consul-datasource/badge)](https://www.codefactor.io/repository/github/sbueringer/grafana-consul-datasource)[![GoReportCard](https://goreportcard.com/badge/github.com/sbueringer/grafana-consul-datasource?style=plastic)](https://goreportcard.com/report/github.com/sbueringer/grafana-consul-datasource)[![GitHub release](https://img.shields.io/github/release/sbueringer/grafana-consul-datasource.svg)](https://github.com/sbueringer/grafana-consul-datasource/releases)

[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sbueringer/consul-datasource/issues)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sbueringer/grafana-consul-datasource/issues)

This datasource lets you integrate key value data from Consul in Grafana dashboards.

Expand Down
Binary file modified dist/grafana-consul-plugin_linux_amd64
Binary file not shown.
5 changes: 3 additions & 2 deletions dist/partials/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3 class="page-heading">Consul</h3>
<div class="gf-form max-width-30">
<span class="gf-form-label width-7">Token</span>
<input type="text" class="gf-form-input" ng-model='ctrl.current.secureJsonData.consulToken'
placeholder="CONSUL_TOKEN" required>
placeholder="CONSUL_TOKEN">
</div>
</div>

Expand All @@ -27,7 +27,8 @@ <h5>Consul Address</h5>
</p>
<h5>Consul Token</h5>
<p>
Consul Token has to be a valid Consul Token which is able to read the values you want to access.
If Consul Token is set, it has to be a valid Consul Token which is able to read the data you want to access.
If Consul Token is not set, "anonymous' is used (see <a href="https://www.consul.io/docs/acl/acl-system.html#acl-tokens">Consul documentation</a>). If ACLs are disabled in Consul, "anonymous" should be able to read the necessary data.
More details can be found in the <a href="https://www.consul.io/docs/guides/acl.html">Consul
documentation</a>.
</p>
Expand Down
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

````
git clone https://github.com/sbueringer/grafana-consul-datasource.git
cd consul-datasource/example
cd grafana-consul-datasource/example
go run main.go
````

Expand Down
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func startServer() *testutil.TestServer {
c.ACLDefaultPolicy = "allow"
c.ACLDatacenter = "default"
c.ACLMasterToken = "master"
c.LogLevel = "warn"
c.LogLevel = "debug"
})
if err != nil {
panic(err)
Expand Down
5 changes: 3 additions & 2 deletions src/partials/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3 class="page-heading">Consul</h3>
<div class="gf-form max-width-30">
<span class="gf-form-label width-7">Token</span>
<input type="text" class="gf-form-input" ng-model='ctrl.current.secureJsonData.consulToken'
placeholder="CONSUL_TOKEN" required>
placeholder="CONSUL_TOKEN">
</div>
</div>

Expand All @@ -27,7 +27,8 @@ <h5>Consul Address</h5>
</p>
<h5>Consul Token</h5>
<p>
Consul Token has to be a valid Consul Token which is able to read the values you want to access.
If Consul Token is set, it has to be a valid Consul Token which is able to read the data you want to access.
If Consul Token is not set, "anonymous' is used (see <a href="https://www.consul.io/docs/acl/acl-system.html#acl-tokens">Consul documentation</a>). If ACLs are disabled in Consul, "anonymous" should be able to read the necessary data.
More details can be found in the <a href="https://www.consul.io/docs/guides/acl.html">Consul
documentation</a>.
</p>
Expand Down

0 comments on commit 5d427f0

Please sign in to comment.