Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 1b82db9

Browse files
julienduchesneYury Bushmelev
andauthored
Fix json_data field types for opentsdb datasource (#64)
`tsdb_resolution` and `tsdb_version` were declared as strings though those fields are integers. See grafana/terraform-provider-grafana#140 Co-authored-by: Yury Bushmelev <yuryb@spgroup.com.sg>
1 parent 98703b6 commit 1b82db9

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

datasource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ type JSONData struct {
117117
Profile string `json:"profile,omitempty"`
118118

119119
// Used by OpenTSDB
120-
TsdbVersion string `json:"tsdbVersion,omitempty"`
121-
TsdbResolution string `json:"tsdbResolution,omitempty"`
120+
TsdbVersion int64 `json:"tsdbVersion,omitempty"`
121+
TsdbResolution int64 `json:"tsdbResolution,omitempty"`
122122

123123
// Used by MSSQL
124124
Encrypt string `json:"encrypt,omitempty"`

datasource_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,31 @@ func TestNewInfluxDBDataSource(t *testing.T) {
170170
t.Error("datasource creation response should return the created datasource ID")
171171
}
172172
}
173+
174+
func TestNewOpenTSDBDataSource(t *testing.T) {
175+
server, client := gapiTestTools(t, 200, createdDataSourceJSON)
176+
defer server.Close()
177+
178+
ds := &DataSource{
179+
Name: "foo_opentsdb",
180+
Type: "opentsdb",
181+
URL: "http://some-url.com",
182+
Access: "access",
183+
IsDefault: true,
184+
JSONData: JSONData{
185+
TsdbResolution: 1,
186+
TsdbVersion: 3,
187+
},
188+
}
189+
190+
created, err := client.NewDataSource(ds)
191+
if err != nil {
192+
t.Fatal(err)
193+
}
194+
195+
t.Log(pretty.PrettyFormat(created))
196+
197+
if created != 1 {
198+
t.Error("datasource creation response should return the created datasource ID")
199+
}
200+
}

0 commit comments

Comments
 (0)