feat: add confd folder
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
kekskurse 2025-08-26 12:55:51 +02:00
parent 0239b0cab2
commit 5be3a1d4e2

View file

@ -63,6 +63,39 @@ func ReadFromFile(path string) (config, error) {
return config{}, fmt.Errorf(ErrWrapTemplate, ErrCantParseConfigFile, err)
}
cfgFolder := "/etc/scron/conf.d/"
if _, err := os.Stat(cfgFolder); os.IsNotExist(err) {
return c, nil
}
entries, err := os.ReadDir("./")
if err != nil {
return c, fmt.Errorf("cant scan confd folder: %w", err)
}
for _, file := range entries {
if !strings.HasSuffix(file.Name(), ".yml") {
continue
}
fileContent, err := os.ReadFile(cfgFolder + file.Name())
if err != nil {
return config{}, fmt.Errorf("cant read config file %s: %w", file.Name(), err)
}
fileConfig := config{}
err = yaml.Unmarshal(fileContent, &fileConfig)
if err != nil {
return config{}, fmt.Errorf("cant unmarshal yml config: %w", err)
}
c.Jobs = append(c.Jobs, fileConfig.Jobs...)
c.Notification = append(c.Notification, fileConfig.Notification...)
}
return c, nil
}