should allow one default datasource per organisation using provisioning

This commit is contained in:
Marcus Efraimsson
2018-08-14 14:48:14 +02:00
parent e521e7b76d
commit aed89b49c0
4 changed files with 45 additions and 4 deletions
@@ -83,7 +83,7 @@ func (cr *configReader) parseDatasourceConfig(path string, file os.FileInfo) (*D
}
func validateDefaultUniqueness(datasources []*DatasourcesAsConfig) error {
defaultCount := 0
defaultCount := map[int64]int{}
for i := range datasources {
if datasources[i].Datasources == nil {
continue
@@ -95,8 +95,8 @@ func validateDefaultUniqueness(datasources []*DatasourcesAsConfig) error {
}
if ds.IsDefault {
defaultCount++
if defaultCount > 1 {
defaultCount[ds.OrgId] = defaultCount[ds.OrgId] + 1
if defaultCount[ds.OrgId] > 1 {
return ErrInvalidConfigToManyDefault
}
}