You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
539 B
Go
40 lines
539 B
Go
package jobs
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
)
|
|
|
|
type Config struct {
|
|
ScriptsDir string `json:"scriptsDir"`
|
|
}
|
|
|
|
type Service struct {
|
|
Config Config
|
|
|
|
scriptPaths []string
|
|
}
|
|
|
|
func New(config Config) *Service {
|
|
return &Service{
|
|
Config: config,
|
|
}
|
|
}
|
|
|
|
func (s *Service) LoadScripts() error {
|
|
entries, err := os.ReadDir(s.Config.ScriptsDir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
s.scriptPaths = []string{}
|
|
|
|
for _, entry := range entries {
|
|
s.scriptPaths = append(s.scriptPaths,
|
|
path.Join(s.Config.ScriptsDir, entry.Name()),
|
|
)
|
|
}
|
|
|
|
return nil
|
|
}
|