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

Commit 98703b6

Browse files
Adding InfluxDB Flux data source support for terraform-provider-grafana (#60)
* Adding InfluxDB Flux data source support for terraform-provider-grafana * Fix module * Fix module * Fix module * Fix module * Use better example of token in tests
1 parent fb984fc commit 98703b6

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

datasource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ type JSONData struct {
161161
// Used by Sentry
162162
OrgSlug string `json:"orgSlug,omitempty"`
163163
URL string `json:"url,omitempty"` // Sentry is not using the datasource URL attribute
164+
165+
// Used by InfluxDB
166+
DefaultBucket string `json:"defaultBucket,omitempty"`
167+
Organization string `json:"organization,omitempty"`
168+
Version string `json:"version,omitempty"`
164169
}
165170

166171
// Required to avoid recursion during (un)marshal

datasource_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,35 @@ func TestNewElasticsearchDataSource(t *testing.T) {
138138
t.Error("datasource creation response should return the created datasource ID")
139139
}
140140
}
141+
142+
func TestNewInfluxDBDataSource(t *testing.T) {
143+
server, client := gapiTestTools(t, 200, createdDataSourceJSON)
144+
defer server.Close()
145+
146+
ds := &DataSource{
147+
Name: "foo_influxdb",
148+
Type: "influxdb",
149+
URL: "http://some-url.com",
150+
IsDefault: true,
151+
JSONData: JSONData{
152+
DefaultBucket: "telegraf",
153+
httpHeaderNames: []string{"Authorization"},
154+
Organization: "acme",
155+
Version: "Flux",
156+
},
157+
SecureJSONData: SecureJSONData{
158+
httpHeaderValues: []string{"Token alksdjaslkdjkslajdkj.asdlkjaksdjlkajsdlkjsaldj=="},
159+
},
160+
}
161+
162+
created, err := client.NewDataSource(ds)
163+
if err != nil {
164+
t.Fatal(err)
165+
}
166+
167+
t.Log(pretty.PrettyFormat(created))
168+
169+
if created != 1 {
170+
t.Error("datasource creation response should return the created datasource ID")
171+
}
172+
}

0 commit comments

Comments
 (0)