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

Added datasource prometheus values for json data #23

Merged
merged 4 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}