Skip to content

Commit 13d677c

Browse files
authored
Update datasource with additional fields (#195)
* Adding additional fields to match: https://grafana.com/docs/grafana/latest/http_api/data_source/ * Addressing code review comments.
1 parent 2ff95a7 commit 13d677c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

datasource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ package sdk
2424
type Datasource struct {
2525
ID uint `json:"id"`
2626
OrgID uint `json:"orgId"`
27+
UID string `json:"uid"`
2728
Name string `json:"name"`
2829
Type string `json:"type"`
30+
TypeLogoURL string `json:"typeLogoUrl"`
2931
Access string `json:"access"` // direct or proxy
3032
URL string `json:"url"`
3133
Password *string `json:"password,omitempty"`
3234
User *string `json:"user,omitempty"`
3335
Database *string `json:"database,omitempty"`
3436
BasicAuth *bool `json:"basicAuth,omitempty"`
37+
ReadOnly *bool `json:"readOnly,omitempty"`
3538
BasicAuthUser *string `json:"basicAuthUser,omitempty"`
3639
BasicAuthPassword *string `json:"basicAuthPassword,omitempty"`
3740
IsDefault bool `json:"isDefault"`

rest-datasource_integration_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package sdk_test
22

33
import (
44
"context"
5+
"fmt"
56
"testing"
67

78
"github.com/grafana-tools/sdk"
9+
"github.com/stretchr/testify/assert"
810
)
911

1012
func Test_Datasource_CRUD(t *testing.T) {
@@ -46,12 +48,15 @@ func Test_Datasource_CRUD(t *testing.T) {
4648
t.Fatal(err)
4749
}
4850

49-
if dsRetrieved.Name != ds.Name {
50-
t.Fatalf("got wrong name: expected %s, was %s", dsRetrieved.Name, ds.Name)
51-
}
51+
assert.Equal(t, dsRetrieved.Name, ds.Name, fmt.Sprintf("got wrong name: expected %s, was %s", dsRetrieved.Name, ds.Name))
52+
//assert.NotNilf(t)
5253

5354
ds.Name = "elasticsdksource"
5455
ds.ID = dsRetrieved.ID
56+
ds.UID = "ZrY0GDS7z"
57+
readOnly := false
58+
ds.ReadOnly = &readOnly
59+
ds.TypeLogoURL = "www.duckduckgo.com"
5560
status, err = client.UpdateDatasource(ctx, ds)
5661
if err != nil {
5762
t.Fatal(err)

0 commit comments

Comments
 (0)