fix: loading ALLOWED_TASKS if empty value passed; chore: update logging for task loading message

This commit is contained in:
jar3b 2019-12-28 21:39:12 +03:00
parent cd5ad5d1ab
commit 70ba06ed5f
2 changed files with 8 additions and 7 deletions

View File

@ -42,16 +42,17 @@ func main() {
initLog(*debug) initLog(*debug)
// get allowed tasks // get allowed tasks
var allowedTasks map[string]bool var allowedTasks *map[string]bool
if os.Getenv("ALLOWED_TASKS") != "" { if os.Getenv("ALLOWED_TASKS") != "" {
allowedTasks = make(map[string]bool, 0) at := make(map[string]bool, 0)
allowedTasks = &at
for _, t := range strings.Split(os.Getenv("ALLOWED_TASKS"), ",") { for _, t := range strings.Split(os.Getenv("ALLOWED_TASKS"), ",") {
allowedTasks[t] = true (*allowedTasks)[t] = true
} }
} }
// manage tasks // manage tasks
taskList, err := tasks.LoadTasks(*configFile, &allowedTasks) taskList, err := tasks.LoadTasks(*configFile, allowedTasks)
if err != nil { if err != nil {
log.Fatalf("cannot load %s: %v", *configFile, err) log.Fatalf("cannot load %s: %v", *configFile, err)
return return

View File

@ -198,10 +198,10 @@ func (di *ConfigDescriptiveInfo) InitTasks(allowedTasksMap *map[string]bool) []e
} }
log.Infof( log.Infof(
"%d tasks loaded - enabled: %s, disabled: %s", "%d tasks loaded - enabled: '%s', disabled: '%s'",
len(di.Tasks), len(di.Tasks),
strings.Join(taskNamesEnabled, ", "), strings.TrimRight(strings.Join(taskNamesEnabled, ", "), ", "),
strings.Join(taskNamesDisabled, ", "), strings.TrimRight(strings.Join(taskNamesDisabled, ", "), ", "),
) )
return errList return errList