Provisioning: Allows specifying uid for datasource and use that in derived fields (#23585)

* Add uid to datasource

* Fix uid passing when provisioning

* Better error handling and Uid column type change

* Fix test and strict null error counts

* Add backend tests

* Add tests

* Fix strict null checks

* Update test

* Improve tests

* Update pkg/services/sqlstore/datasource.go

Co-Authored-By: Arve Knudsen <arve.knudsen@gmail.com>

* Variable rename

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Andrej Ocenas
2020-04-20 15:48:38 +02:00
committed by GitHub
co-authored by Arve Knudsen
parent d5f8d976f0
commit e5dd7efdee
34 changed files with 446 additions and 204 deletions
+10 -5
View File
@@ -28,11 +28,13 @@ const (
)
var (
ErrDataSourceNotFound = errors.New("Data source not found")
ErrDataSourceNameExists = errors.New("Data source with same name already exists")
ErrDataSourceUpdatingOldVersion = errors.New("Trying to update old version of datasource")
ErrDatasourceIsReadOnly = errors.New("Data source is readonly. Can only be updated from configuration")
ErrDataSourceAccessDenied = errors.New("Data source access denied")
ErrDataSourceNotFound = errors.New("Data source not found")
ErrDataSourceNameExists = errors.New("Data source with the same name already exists")
ErrDataSourceUidExists = errors.New("Data source with the same uid already exists")
ErrDataSourceUpdatingOldVersion = errors.New("Trying to update old version of datasource")
ErrDatasourceIsReadOnly = errors.New("Data source is readonly. Can only be updated from configuration")
ErrDataSourceAccessDenied = errors.New("Data source access denied")
ErrDataSourceFailedGenerateUniqueUid = errors.New("Failed to generate unique datasource id")
)
type DsAccess string
@@ -57,6 +59,7 @@ type DataSource struct {
JsonData *simplejson.Json
SecureJsonData securejsondata.SecureJsonData
ReadOnly bool
Uid string
Created time.Time
Updated time.Time
@@ -144,6 +147,7 @@ type AddDataSourceCommand struct {
IsDefault bool `json:"isDefault"`
JsonData *simplejson.Json `json:"jsonData"`
SecureJsonData map[string]string `json:"secureJsonData"`
Uid string `json:"uid"`
OrgId int64 `json:"-"`
ReadOnly bool `json:"-"`
@@ -168,6 +172,7 @@ type UpdateDataSourceCommand struct {
JsonData *simplejson.Json `json:"jsonData"`
SecureJsonData map[string]string `json:"secureJsonData"`
Version int `json:"version"`
Uid string `json:"uid"`
OrgId int64 `json:"-"`
Id int64 `json:"-"`