|
|
@@ -17,27 +17,29 @@ type DataSourceFromConfig struct {
|
|
|
OrgId int64 `json:"org_id" yaml:"org_id"`
|
|
|
Version int `json:"version" yaml:"version"`
|
|
|
|
|
|
- Name string `json:"name" yaml:"name"`
|
|
|
- Type string `json:"type" yaml:"type"`
|
|
|
- Access string `json:"access" yaml:"access"`
|
|
|
- Url string `json:"url" yaml:"url"`
|
|
|
- Password string `json:"password" yaml:"password"`
|
|
|
- User string `json:"user" yaml:"user"`
|
|
|
- Database string `json:"database" yaml:"database"`
|
|
|
- BasicAuth bool `json:"basic_auth" yaml:"basic_auth"`
|
|
|
- BasicAuthUser string `json:"basic_auth_user" yaml:"basic_auth_user"`
|
|
|
- BasicAuthPassword string `json:"basic_auth_password" yaml:"basic_auth_password"`
|
|
|
- WithCredentials bool `json:"with_credentials" yaml:"with_credentials"`
|
|
|
- IsDefault bool `json:"is_default" yaml:"is_default"`
|
|
|
- JsonData string `json:"json_data" yaml:"json_data"`
|
|
|
- SecureJsonData map[string]string `json:"secure_json_data" yaml:"secure_json_data"`
|
|
|
- Editable bool `json:"editable" yaml:"editable"`
|
|
|
+ Name string `json:"name" yaml:"name"`
|
|
|
+ Type string `json:"type" yaml:"type"`
|
|
|
+ Access string `json:"access" yaml:"access"`
|
|
|
+ Url string `json:"url" yaml:"url"`
|
|
|
+ Password string `json:"password" yaml:"password"`
|
|
|
+ User string `json:"user" yaml:"user"`
|
|
|
+ Database string `json:"database" yaml:"database"`
|
|
|
+ BasicAuth bool `json:"basic_auth" yaml:"basic_auth"`
|
|
|
+ BasicAuthUser string `json:"basic_auth_user" yaml:"basic_auth_user"`
|
|
|
+ BasicAuthPassword string `json:"basic_auth_password" yaml:"basic_auth_password"`
|
|
|
+ WithCredentials bool `json:"with_credentials" yaml:"with_credentials"`
|
|
|
+ IsDefault bool `json:"is_default" yaml:"is_default"`
|
|
|
+ JsonData map[string]interface{} `json:"json_data" yaml:"json_data"`
|
|
|
+ SecureJsonData map[string]string `json:"secure_json_data" yaml:"secure_json_data"`
|
|
|
+ Editable bool `json:"editable" yaml:"editable"`
|
|
|
}
|
|
|
|
|
|
func createInsertCommand(ds *DataSourceFromConfig) *models.AddDataSourceCommand {
|
|
|
- jsonData, err := simplejson.NewJson([]byte(ds.JsonData))
|
|
|
- if err != nil {
|
|
|
- jsonData = simplejson.New()
|
|
|
+ jsonData := simplejson.New()
|
|
|
+ if len(ds.JsonData) > 0 {
|
|
|
+ for k, v := range ds.JsonData {
|
|
|
+ jsonData.Set(k, v)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return &models.AddDataSourceCommand{
|
|
|
@@ -61,9 +63,11 @@ func createInsertCommand(ds *DataSourceFromConfig) *models.AddDataSourceCommand
|
|
|
}
|
|
|
|
|
|
func createUpdateCommand(ds *DataSourceFromConfig, id int64) *models.UpdateDataSourceCommand {
|
|
|
- jsonData, err := simplejson.NewJson([]byte(ds.JsonData))
|
|
|
- if err != nil {
|
|
|
- jsonData = simplejson.New()
|
|
|
+ jsonData := simplejson.New()
|
|
|
+ if len(ds.JsonData) > 0 {
|
|
|
+ for k, v := range ds.JsonData {
|
|
|
+ jsonData.Set(k, v)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return &models.UpdateDataSourceCommand{
|