Signed-off-by: blob42 <contact@blob42.xyz>
This commit is contained in:
blob42 2024-10-10 18:21:41 +02:00
parent ac6819ec94
commit 857e7625db
2 changed files with 9 additions and 13 deletions

View File

@ -132,12 +132,12 @@ func GetModuleOption(module string, opt string) (interface{}, error) {
return nil, fmt.Errorf("module %s not found", module) return nil, fmt.Errorf("module %s not found", module)
} }
// Regiser a module option ie. under [module] in toml file
// If the module is not a configurator, a simple map[string]interface{} will be
// created for it.
// TODO: check if generics can be used here to avoid interface{} type // TODO: check if generics can be used here to avoid interface{} type
// TODO: add support for option description that can be used in cli help // TODO: add support for option description that can be used in cli help
// Register a module option ie. under [module] in toml file
// If the module is not a configurator, a simple map[string]interface{} will be
// created for it.
func RegisterModuleOpt(module string, opt string, val interface{}) error { func RegisterModuleOpt(module string, opt string, val interface{}) error {
log.Debugf("Setting option for module <%s>: %s = %v", module, opt, val) log.Debugf("Setting option for module <%s>: %s = %v", module, opt, val)
if _, ok := configs[module]; !ok { if _, ok := configs[module]; !ok {
@ -149,9 +149,6 @@ func RegisterModuleOpt(module string, opt string, val interface{}) error {
return err return err
} }
//DEBUG:
// watchAll, _ := configs[module].Get("WatchAllProfiles")
// log.Debugf("[%s]WATCH_ALL: %v", module, watchAll)
return nil return nil
} }

View File

@ -121,15 +121,13 @@ func LoadFromTomlFile() error {
return fmt.Errorf("loading config file %w", err) return fmt.Errorf("loading config file %w", err)
} }
//DEBUG:
// fmt.Println("Mem Config Keys:") // fmt.Println("Mem Config Keys:")
// for k, _ := range configs { // for k, _ := range configs {
// fmt.Printf("%#v\n", k) // fmt.Printf("%#v\n", k)
// } // }
for k, val := range buffer { for k, val := range buffer {
// fmt.Println("File Config Keys:")
// fmt.Printf("%#v\n", k)
// send the conf to its own module // send the conf to its own module
if _, ok := configs[k]; !ok { if _, ok := configs[k]; !ok {
log.Debugf("creating module config [%s]", k) log.Debugf("creating module config [%s]", k)
@ -143,9 +141,10 @@ func LoadFromTomlFile() error {
} }
log.Debugf("loaded config from %s\n", configFile) //DEBUG:
log.Debugf("config file %#v\n", buffer) // log.Debugf("loaded config from %s\n", configFile)
log.Debugf("loaded config %#v", configs) // log.Debugf("config file %#v\n", buffer)
// log.Debugf("loaded config %#v", configs)
return err return err
} }