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

Commit

Permalink
parse integers from consul instead of always strings
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Sep 21, 2018
1 parent 9f809a4 commit 60f73d5
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 106 deletions.
8 changes: 6 additions & 2 deletions datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,15 @@ func handleTable(consul *api.Client, qs []query) *datasource.DatasourceResponse
kv, _, err := consul.KV().Get(colKey, &api.QueryOptions{})
var kvValue string
if err != nil || kv == nil {
kvValue = "Not Found"
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_STRING, StringValue: "Not Found"})
} else {
kvValue = string(kv.Value)
if i, err := strconv.ParseInt(kvValue, 10, 64); err != nil {
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_STRING, StringValue: kvValue})
} else {
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_INT64, Int64Value: i})
}
}
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_STRING, StringValue: kvValue})
}
tableRows = append(tableRows, &datasource.TableRow{Values: tableRowValues})
}
Expand Down
Binary file modified dist/grafana-consul-plugin_linux_amd64
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
{"name": "GitHub", "url": "https://github.com/sbueringer/grafana-consul-datasource"},
{"name": "Apache License 2.0", "url": "https://github.com/sbueringer/grafana-consul-datasource/blob/master/LICENSE"}
],
"version": "0.1.4",
"updated": "2018-09-07"
"version": "0.1.5",
"updated": "2018-09-21"
},

"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
{"name": "GitHub", "url": "https://github.com/sbueringer/grafana-consul-datasource"},
{"name": "Apache License 2.0", "url": "https://github.com/sbueringer/grafana-consul-datasource/blob/master/LICENSE"}
],
"version": "0.1.4",
"updated": "2018-09-07"
"version": "0.1.5",
"updated": "2018-09-21"
},

"dependencies": {
Expand Down
Loading

0 comments on commit 60f73d5

Please sign in to comment.