mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
provisioning: handle nil configs
This commit is contained in:
parent
3091697a2c
commit
165304a342
@ -57,6 +57,10 @@ func (cr *configReader) parseDatasourceConfig(path string, file os.FileInfo) (*D
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if apiVersion == nil {
|
||||
apiVersion = &ConfigVersion{ApiVersion: 0}
|
||||
}
|
||||
|
||||
if apiVersion.ApiVersion > 0 {
|
||||
var v1 *DatasourcesAsConfigV1
|
||||
err = yaml.Unmarshal(yamlFile, &v1)
|
||||
|
@ -111,6 +111,10 @@ func (cfg *DatasourcesAsConfigV1) mapToDatasourceFromConfig(apiVersion int64) *D
|
||||
|
||||
r.ApiVersion = apiVersion
|
||||
|
||||
if cfg == nil {
|
||||
return r
|
||||
}
|
||||
|
||||
for _, ds := range cfg.Datasources {
|
||||
r.Datasources = append(r.Datasources, &DataSourceFromConfig{
|
||||
OrgId: ds.OrgId,
|
||||
@ -148,6 +152,10 @@ func (cfg *DatasourcesAsConfigV0) mapToDatasourceFromConfig(apiVersion int64) *D
|
||||
|
||||
r.ApiVersion = apiVersion
|
||||
|
||||
if cfg == nil {
|
||||
return r
|
||||
}
|
||||
|
||||
for _, ds := range cfg.Datasources {
|
||||
r.Datasources = append(r.Datasources, &DataSourceFromConfig{
|
||||
OrgId: ds.OrgId,
|
||||
|
Loading…
Reference in New Issue
Block a user