fix reading toml for output and database
This commit is contained in:
parent
18c0362021
commit
773545643c
|
@ -23,16 +23,12 @@ func Connect(allConnection map[string]interface{}) (database.Connection, error)
|
||||||
log.WithField("database", dbType).Infof("no configuration found")
|
log.WithField("database", dbType).Infof("no configuration found")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dbConfigs, ok := configForType.([]interface{})
|
dbConfigs, ok := configForType.([]map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("the database type '%s' has the wrong format", dbType)
|
return nil, fmt.Errorf("the database type '%s' has the wrong format: read format %T should be an []map[string]interface{}", dbType, configForType)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dbConfig := range dbConfigs {
|
for _, config := range dbConfigs {
|
||||||
config, ok := dbConfig.(map[string]interface{})
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("the database type '%s' has the wrong format", dbType)
|
|
||||||
}
|
|
||||||
if c, ok := config["enable"].(bool); ok && !c {
|
if c, ok := config["enable"].(bool); ok && !c {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,11 @@ func Register(configuration map[string]interface{}) (output.Output, error) {
|
||||||
log.WithField("output", outputType).Infof("no configuration found")
|
log.WithField("output", outputType).Infof("no configuration found")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
outputConfigs, ok := configForOutput.([]interface{})
|
outputConfigs, ok := configForOutput.([]map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("the output type '%s' has the wrong format", outputType)
|
return nil, fmt.Errorf("the output type '%s' has the wrong format: read format %T should be an []map[string]interface{}", outputType, configForOutput)
|
||||||
}
|
|
||||||
for _, outputConfig := range outputConfigs {
|
|
||||||
config, ok := outputConfig.(map[string]interface{})
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("the output type '%s' has the wrong format", outputType)
|
|
||||||
}
|
}
|
||||||
|
for _, config := range outputConfigs {
|
||||||
if c, ok := config["enable"].(bool); ok && !c {
|
if c, ok := config["enable"].(bool); ok && !c {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue