mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Add print_config flags to cgr-loader and cgr-migrator
This commit is contained in:
committed by
Dan Christian Bogos
parent
b88602cdf3
commit
23ae4632fe
@@ -41,7 +41,8 @@ var (
|
||||
dfltCfg = config.CgrConfig()
|
||||
cfgPath = cgrLoaderFlags.String(utils.CfgPathCgr, utils.EmptyString,
|
||||
"Configuration directory path.")
|
||||
dataDBType = cgrLoaderFlags.String(utils.DataDBTypeCgr, dfltCfg.DataDbCfg().Type,
|
||||
printConfig = cgrLoaderFlags.Bool(utils.PrintCfgCgr, false, "Print the configuration object in JSON format")
|
||||
dataDBType = cgrLoaderFlags.String(utils.DataDBTypeCgr, dfltCfg.DataDbCfg().Type,
|
||||
"The type of the DataDB database <*redis|*mongo>")
|
||||
dataDBHost = cgrLoaderFlags.String(utils.DataDBHostCgr, dfltCfg.DataDbCfg().Host,
|
||||
"The DataDb host to connect to.")
|
||||
@@ -402,7 +403,10 @@ func main() {
|
||||
if *dryRun { // We were just asked to parse the data, not saving it
|
||||
return
|
||||
}
|
||||
|
||||
if *printConfig {
|
||||
cfgJSON := utils.ToIJSON(ldrCfg.AsMapInterface(ldrCfg.GeneralCfg().RSRSep))
|
||||
log.Printf("Configuration loaded from %q:\n%s", *cfgPath, cfgJSON)
|
||||
}
|
||||
if *remove {
|
||||
if err = tpReader.RemoveFromDatabase(*verbose, *disableReverse); err != nil {
|
||||
log.Fatal("Could not delete from database: ", err)
|
||||
|
||||
@@ -30,6 +30,12 @@ func TestCGRLoaderFlags(t *testing.T) {
|
||||
t.Errorf("Expected /etc/cgrates, received %+v", *cfgPath)
|
||||
}
|
||||
|
||||
if err := cgrLoaderFlags.Parse([]string{"-print_config", "true"}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if *printConfig != true {
|
||||
t.Errorf("Expected true, received %+v", *printConfig)
|
||||
}
|
||||
|
||||
if err := cgrLoaderFlags.Parse([]string{"-datadb_type", "*redis"}); err != nil {
|
||||
t.Error(err)
|
||||
} else if *dataDBType != "*redis" {
|
||||
|
||||
@@ -44,8 +44,8 @@ var (
|
||||
dfltCfg = config.NewDefaultCGRConfig()
|
||||
cfgPath = cgrMigratorFlags.String(utils.CfgPathCgr, utils.EmptyString,
|
||||
"Configuration directory path.")
|
||||
|
||||
exec = cgrMigratorFlags.String(utils.ExecCgr, utils.EmptyString, "fire up automatic migration "+
|
||||
printConfig = cgrMigratorFlags.Bool(utils.PrintCfgCgr, false, "Print the configuration object in JSON format")
|
||||
exec = cgrMigratorFlags.String(utils.ExecCgr, utils.EmptyString, "fire up automatic migration "+
|
||||
"<*set_versions|*cost_details|*accounts|*actions|*action_triggers|*action_plans|*shared_groups|*filters|*stordb|*datadb>")
|
||||
version = cgrMigratorFlags.Bool(utils.VersionCgr, false, "prints the application version")
|
||||
|
||||
@@ -404,6 +404,11 @@ func main() {
|
||||
mgrCfg.MigratorCgrCfg().OutStorDBPort == mgrCfg.MigratorCgrCfg().OutDataDBPort &&
|
||||
mgrCfg.MigratorCgrCfg().OutStorDBName == mgrCfg.MigratorCgrCfg().OutDataDBName
|
||||
|
||||
if *printConfig {
|
||||
cfgJSON := utils.ToIJSON(mgrCfg.AsMapInterface(mgrCfg.GeneralCfg().RSRSep))
|
||||
log.Printf("Configuration loaded from %q:\n%s", *cfgPath, cfgJSON)
|
||||
}
|
||||
|
||||
m, err := migrator.NewMigrator(dmIN, dmOUT,
|
||||
storDBIn, storDBOut,
|
||||
*dryRun, sameDataDB, sameStorDB, sameOutDB)
|
||||
|
||||
@@ -31,6 +31,11 @@ func TestFlags(t *testing.T) {
|
||||
} else if *cfgPath != "true" {
|
||||
t.Errorf("Expected true received:%v ", *cfgPath)
|
||||
}
|
||||
if err := cgrMigratorFlags.Parse([]string{"-print_config", "true"}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if *printConfig != true {
|
||||
t.Errorf("Expected true, received %+v", *printConfig)
|
||||
}
|
||||
if err := cgrMigratorFlags.Parse([]string{"-exec", "true"}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if *exec != "true" {
|
||||
|
||||
Reference in New Issue
Block a user