provisioning: handle nil configs

This commit is contained in:
bergquist 2018-02-14 11:22:24 +01:00
parent 3091697a2c
commit 165304a342
2 changed files with 12 additions and 0 deletions

View File

@ -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)

View File

@ -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,