serverconfig: fix generated low-level config for mysql indexer

Change-Id: I8376bf134cf234b1a671aaacffba98fe5eaf3271
This commit is contained in:
Brad Fitzpatrick 2012-04-11 19:22:02 -07:00
parent c6e6f7a92d
commit 7b8105d561
1 changed files with 17 additions and 10 deletions

View File

@ -206,7 +206,17 @@ func GenLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
dbname = "camli" + username
}
indexerPath := "/index-mem/"
var indexerPath string
switch {
case mongo != "" && mysql != "":
return nil, fmt.Errorf("Cannot have both mysql and mongo in config, pick one")
case mysql != "":
indexerPath = "/index-mysql/"
case mongo != "":
indexerPath = "/index-mongo/"
default:
indexerPath = "/index-mem/"
}
prefixesParams := &configPrefixesParams{
secretRing: secretRing,
@ -223,17 +233,14 @@ func GenLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
addUiConfig(&prefixes, "/ui/")
if mongo != "" && mysql != "" {
return nil, fmt.Errorf("Cannot have both mysql and mongo in config, pick one")
}
if mysql != "" {
addMysqlConfig(&prefixes, dbname, mysql)
} else {
if mongo != "" {
addMongoConfig(&prefixes, dbname, mongo)
} else {
addMemindexConfig(&prefixes)
}
}
if mongo != "" {
addMongoConfig(&prefixes, dbname, mongo)
}
if indexerPath == "/index-mem/" {
addMemindexConfig(&prefixes)
}
obj["prefixes"] = (map[string]interface{})(prefixes)