mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
add with_credentials to datasource model
This commit is contained in:
parent
f1bc87133d
commit
6edd6c8f03
@ -65,6 +65,7 @@ func GetDataSourceById(c *middleware.Context) Response {
|
|||||||
BasicAuth: ds.BasicAuth,
|
BasicAuth: ds.BasicAuth,
|
||||||
BasicAuthUser: ds.BasicAuthUser,
|
BasicAuthUser: ds.BasicAuthUser,
|
||||||
BasicAuthPassword: ds.BasicAuthPassword,
|
BasicAuthPassword: ds.BasicAuthPassword,
|
||||||
|
WithCredentials: ds.WithCredentials,
|
||||||
IsDefault: ds.IsDefault,
|
IsDefault: ds.IsDefault,
|
||||||
JsonData: ds.JsonData,
|
JsonData: ds.JsonData,
|
||||||
})
|
})
|
||||||
|
@ -61,6 +61,7 @@ type DataSource struct {
|
|||||||
BasicAuth bool `json:"basicAuth"`
|
BasicAuth bool `json:"basicAuth"`
|
||||||
BasicAuthUser string `json:"basicAuthUser"`
|
BasicAuthUser string `json:"basicAuthUser"`
|
||||||
BasicAuthPassword string `json:"basicAuthPassword"`
|
BasicAuthPassword string `json:"basicAuthPassword"`
|
||||||
|
WithCredentials bool `json:"withCredentials"`
|
||||||
IsDefault bool `json:"isDefault"`
|
IsDefault bool `json:"isDefault"`
|
||||||
JsonData map[string]interface{} `json:"jsonData"`
|
JsonData map[string]interface{} `json:"jsonData"`
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,9 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
|
|||||||
if ds.BasicAuth {
|
if ds.BasicAuth {
|
||||||
dsMap["basicAuth"] = util.GetBasicAuthHeader(ds.BasicAuthUser, ds.BasicAuthPassword)
|
dsMap["basicAuth"] = util.GetBasicAuthHeader(ds.BasicAuthUser, ds.BasicAuthPassword)
|
||||||
}
|
}
|
||||||
|
if ds.WithCredentials {
|
||||||
|
dsMap["withCredentials"] = ds.WithCredentials
|
||||||
|
}
|
||||||
|
|
||||||
if ds.Type == m.DS_INFLUXDB_08 {
|
if ds.Type == m.DS_INFLUXDB_08 {
|
||||||
dsMap["username"] = ds.User
|
dsMap["username"] = ds.User
|
||||||
|
@ -40,6 +40,7 @@ type DataSource struct {
|
|||||||
BasicAuth bool
|
BasicAuth bool
|
||||||
BasicAuthUser string
|
BasicAuthUser string
|
||||||
BasicAuthPassword string
|
BasicAuthPassword string
|
||||||
|
WithCredentials bool
|
||||||
IsDefault bool
|
IsDefault bool
|
||||||
JsonData map[string]interface{}
|
JsonData map[string]interface{}
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ type AddDataSourceCommand struct {
|
|||||||
BasicAuth bool `json:"basicAuth"`
|
BasicAuth bool `json:"basicAuth"`
|
||||||
BasicAuthUser string `json:"basicAuthUser"`
|
BasicAuthUser string `json:"basicAuthUser"`
|
||||||
BasicAuthPassword string `json:"basicAuthPassword"`
|
BasicAuthPassword string `json:"basicAuthPassword"`
|
||||||
|
WithCredentials bool `json:"withCredentials"`
|
||||||
IsDefault bool `json:"isDefault"`
|
IsDefault bool `json:"isDefault"`
|
||||||
JsonData map[string]interface{} `json:"jsonData"`
|
JsonData map[string]interface{} `json:"jsonData"`
|
||||||
|
|
||||||
@ -103,6 +105,7 @@ type UpdateDataSourceCommand struct {
|
|||||||
BasicAuth bool `json:"basicAuth"`
|
BasicAuth bool `json:"basicAuth"`
|
||||||
BasicAuthUser string `json:"basicAuthUser"`
|
BasicAuthUser string `json:"basicAuthUser"`
|
||||||
BasicAuthPassword string `json:"basicAuthPassword"`
|
BasicAuthPassword string `json:"basicAuthPassword"`
|
||||||
|
WithCredentials bool `json:"withCredentials"`
|
||||||
IsDefault bool `json:"isDefault"`
|
IsDefault bool `json:"isDefault"`
|
||||||
JsonData map[string]interface{} `json:"jsonData"`
|
JsonData map[string]interface{} `json:"jsonData"`
|
||||||
|
|
||||||
|
@ -114,12 +114,14 @@ func UpdateDataSource(cmd *m.UpdateDataSourceCommand) error {
|
|||||||
BasicAuth: cmd.BasicAuth,
|
BasicAuth: cmd.BasicAuth,
|
||||||
BasicAuthUser: cmd.BasicAuthUser,
|
BasicAuthUser: cmd.BasicAuthUser,
|
||||||
BasicAuthPassword: cmd.BasicAuthPassword,
|
BasicAuthPassword: cmd.BasicAuthPassword,
|
||||||
|
WithCredentials: cmd.WithCredentials,
|
||||||
JsonData: cmd.JsonData,
|
JsonData: cmd.JsonData,
|
||||||
Updated: time.Now(),
|
Updated: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.UseBool("is_default")
|
sess.UseBool("is_default")
|
||||||
sess.UseBool("basic_auth")
|
sess.UseBool("basic_auth")
|
||||||
|
sess.UseBool("with_credentials")
|
||||||
|
|
||||||
_, err := sess.Where("id=? and org_id=?", ds.Id, ds.OrgId).Update(ds)
|
_, err := sess.Where("id=? and org_id=?", ds.Id, ds.OrgId).Update(ds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -96,4 +96,9 @@ func addDataSourceMigration(mg *Migrator) {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
mg.AddMigration("Drop old table data_source_v1 #2", NewDropTableMigration("data_source_v1"))
|
mg.AddMigration("Drop old table data_source_v1 #2", NewDropTableMigration("data_source_v1"))
|
||||||
|
|
||||||
|
// add column to activate withCredentials option
|
||||||
|
mg.AddMigration("Add column with_credentials", NewAddColumnMigration(tableV2, &Column{
|
||||||
|
Name: "with_credentials", Type: DB_Bool, Nullable: false, Default: "0",
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,10 @@ type AddColumnMigration struct {
|
|||||||
column *Column
|
column *Column
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewAddColumnMigration(table Table, col *Column) *AddColumnMigration {
|
||||||
|
return &AddColumnMigration{tableName: table.Name, column: col}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *AddColumnMigration) Table(tableName string) *AddColumnMigration {
|
func (m *AddColumnMigration) Table(tableName string) *AddColumnMigration {
|
||||||
m.tableName = tableName
|
m.tableName = tableName
|
||||||
return m
|
return m
|
||||||
|
Loading…
Reference in New Issue
Block a user