Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Added missing datasource fields #30

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -25,3 +25,4 @@ _testmain.go

# vim swap files
.*.sw?
.idea
3 changes: 3 additions & 0 deletions datasource.go
Original file line number Diff line number Diff line change
@@ -37,6 +37,9 @@ type JSONData struct {
CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"`
DefaultRegion string `json:"defaultRegion,omitempty"`
TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"`
HttpMethod string `json:"httpMethod,omitempty"`
QueryTimeout string `json:"queryTimeout,omitempty"`
TimeInterval string `json:"timeInterval,omitempty"`
}

// SecureJSONData is a representation of the datasource `secureJsonData` property
29 changes: 29 additions & 0 deletions datasource_test.go
Original file line number Diff line number Diff line change
@@ -73,3 +73,32 @@ func TestNewDataSource(t *testing.T) {
t.Error("datasource creation response should return the created datasource ID")
}
}

func TestNewPrometheusDataSource(t *testing.T) {
server, client := gapiTestTools(200, createdDataSourceJSON)
defer server.Close()

ds := &DataSource{
Name: "foo_prometheus",
Type: "prometheus",
URL: "http://some-url.com",
Access: "access",
IsDefault: true,
JSONData: JSONData{
HttpMethod: "POST",
QueryTimeout: "60s",
TimeInterval: "1m",
},
}

created, err := client.NewDataSource(ds)
if err != nil {
t.Error(err)
}

t.Log(pretty.PrettyFormat(created))

if created != 1 {
t.Error("datasource creation response should return the created datasource ID")
}
}