organize models
This commit is contained in:
@@ -25,14 +25,14 @@ func TestConverter(t *testing.T) {
|
||||
}
|
||||
for _, name := range check {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
fpath := filepath.Join("testdata", name+"-input.json")
|
||||
fpath := filepath.Join("testdata", name+".json")
|
||||
raw, err := os.ReadFile(fpath) // nolint:gosec
|
||||
require.NoError(t, err)
|
||||
err = json.Unmarshal(raw, obj)
|
||||
require.NoError(t, err)
|
||||
|
||||
// The add command
|
||||
fpath = filepath.Join("testdata", name+"-output-add.json")
|
||||
fpath = filepath.Join("testdata", name+"-cmd-add.json")
|
||||
add, err := converter.toAddCommand(obj)
|
||||
require.NoError(t, err)
|
||||
out, err := json.MarshalIndent(add, "", " ")
|
||||
@@ -43,7 +43,7 @@ func TestConverter(t *testing.T) {
|
||||
}
|
||||
|
||||
// The update command
|
||||
fpath = filepath.Join("testdata", name+"-output-update.json")
|
||||
fpath = filepath.Join("testdata", name+"-cmd-update.json")
|
||||
update, err := converter.toUpdateCommand(obj)
|
||||
require.NoError(t, err)
|
||||
out, err = json.MarshalIndent(update, "", " ")
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "cejobd88i85j4d",
|
||||
"namespace": "default",
|
||||
"uid": "IGIUtEQS21DtLpBG2rSGfuDoUX8cwsGrtb5aXauYeA4X",
|
||||
"resourceVersion": "1745320815000",
|
||||
"generation": 2,
|
||||
"creationTimestamp": "2025-04-22T11:20:11Z"
|
||||
},
|
||||
"spec": {
|
||||
"title": "grafana-testdata-datasource",
|
||||
"access": "proxy",
|
||||
"isDefault": true,
|
||||
"url": "http://something/",
|
||||
"database": "db",
|
||||
"jsonData": {
|
||||
"aaa": "bbb",
|
||||
"bbb": true,
|
||||
"ccc": 1.234
|
||||
}
|
||||
},
|
||||
"secure": {
|
||||
"password": { "input": "XXXX" }
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "grafana-testdata-datasource",
|
||||
"type": "test-datasource",
|
||||
"access": "proxy",
|
||||
"url": "http://something/",
|
||||
"database": "db",
|
||||
"user": "",
|
||||
"basicAuth": false,
|
||||
"basicAuthUser": "",
|
||||
"withCredentials": false,
|
||||
"isDefault": true,
|
||||
"jsonData": {
|
||||
"aaa": "bbb",
|
||||
"bbb": true,
|
||||
"ccc": 1.234
|
||||
},
|
||||
"secureJsonData": {
|
||||
"password": "XXXX"
|
||||
},
|
||||
"uid": "cejobd88i85j4d",
|
||||
"apiVersion": "",
|
||||
"IsPrunable": false
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "grafana-testdata-datasource",
|
||||
"type": "test-datasource",
|
||||
"access": "proxy",
|
||||
"url": "http://something/",
|
||||
"user": "",
|
||||
"database": "db",
|
||||
"basicAuth": false,
|
||||
"basicAuthUser": "",
|
||||
"withCredentials": false,
|
||||
"isDefault": true,
|
||||
"jsonData": {
|
||||
"aaa": "bbb",
|
||||
"bbb": true,
|
||||
"ccc": 1.234
|
||||
},
|
||||
"secureJsonData": {
|
||||
"password": "XXXX"
|
||||
},
|
||||
"version": 2,
|
||||
"uid": "cejobd88i85j4d",
|
||||
"apiVersion": "",
|
||||
"IsPrunable": false
|
||||
}
|
||||
@@ -156,8 +156,8 @@ type AddDataSourceCommand struct {
|
||||
Type string `json:"type" binding:"Required"`
|
||||
Access DsAccess `json:"access" binding:"Required"`
|
||||
URL string `json:"url"`
|
||||
Database string `json:"database"`
|
||||
User string `json:"user"`
|
||||
Database string `json:"database"`
|
||||
BasicAuth bool `json:"basicAuth"`
|
||||
BasicAuthUser string `json:"basicAuthUser"`
|
||||
WithCredentials bool `json:"withCredentials"`
|
||||
@@ -166,9 +166,9 @@ type AddDataSourceCommand struct {
|
||||
SecureJsonData map[string]string `json:"secureJsonData"`
|
||||
UID string `json:"uid"`
|
||||
// swagger:ignore
|
||||
APIVersion string `json:"apiVersion"`
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
// swagger:ignore
|
||||
IsPrunable bool
|
||||
IsPrunable bool `json:"-"`
|
||||
|
||||
OrgID int64 `json:"-"`
|
||||
UserID int64 `json:"-"`
|
||||
@@ -191,12 +191,15 @@ type UpdateDataSourceCommand struct {
|
||||
IsDefault bool `json:"isDefault"`
|
||||
JsonData *simplejson.Json `json:"jsonData"`
|
||||
SecureJsonData map[string]string `json:"secureJsonData"`
|
||||
Version int `json:"version"`
|
||||
UID string `json:"uid"`
|
||||
// swagger:ignore
|
||||
APIVersion string `json:"apiVersion"`
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
// swagger:ignore
|
||||
IsPrunable bool
|
||||
IsPrunable bool `json:"-"`
|
||||
// Everything above is identical in AddDataSourceCommand
|
||||
|
||||
// The previous version -- used for optimistic locking
|
||||
Version int `json:"version"`
|
||||
|
||||
OrgID int64 `json:"-"`
|
||||
ID int64 `json:"-"`
|
||||
|
||||
Reference in New Issue
Block a user