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

Commit 60f73d5

Browse files
committed
parse integers from consul instead of always strings
1 parent 9f809a4 commit 60f73d5

File tree

5 files changed

+110
-106
lines changed

5 files changed

+110
-106
lines changed

datasource.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,15 @@ func handleTable(consul *api.Client, qs []query) *datasource.DatasourceResponse
216216
kv, _, err := consul.KV().Get(colKey, &api.QueryOptions{})
217217
var kvValue string
218218
if err != nil || kv == nil {
219-
kvValue = "Not Found"
219+
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_STRING, StringValue: "Not Found"})
220220
} else {
221221
kvValue = string(kv.Value)
222+
if i, err := strconv.ParseInt(kvValue, 10, 64); err != nil {
223+
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_STRING, StringValue: kvValue})
224+
} else {
225+
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_INT64, Int64Value: i})
226+
}
222227
}
223-
tableRowValues = append(tableRowValues, &datasource.RowValue{Kind: datasource.RowValue_TYPE_STRING, StringValue: kvValue})
224228
}
225229
tableRows = append(tableRows, &datasource.TableRow{Values: tableRowValues})
226230
}
4 KB
Binary file not shown.

dist/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
{"name": "GitHub", "url": "https://github.com/sbueringer/grafana-consul-datasource"},
3131
{"name": "Apache License 2.0", "url": "https://github.com/sbueringer/grafana-consul-datasource/blob/master/LICENSE"}
3232
],
33-
"version": "0.1.4",
34-
"updated": "2018-09-07"
33+
"version": "0.1.5",
34+
"updated": "2018-09-21"
3535
},
3636

3737
"dependencies": {

src/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
{"name": "GitHub", "url": "https://github.com/sbueringer/grafana-consul-datasource"},
3131
{"name": "Apache License 2.0", "url": "https://github.com/sbueringer/grafana-consul-datasource/blob/master/LICENSE"}
3232
],
33-
"version": "0.1.4",
34-
"updated": "2018-09-07"
33+
"version": "0.1.5",
34+
"updated": "2018-09-21"
3535
},
3636

3737
"dependencies": {

0 commit comments

Comments
 (0)