Skip to content

Commit

Permalink
Resolves #304 - Add warning if EPCC runbook directory is not found (#305
Browse files Browse the repository at this point in the history
)
  • Loading branch information
steve-r-west authored May 11, 2023
1 parent 435db1e commit 015e4f2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions external/runbooks/runbooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,21 @@ func init() {
func InitializeBuiltInRunbooks() {
LoadBuiltInRunbooks(embeddedRunbooks)
if config.Envs.EPCC_RUNBOOK_DIRECTORY != "" {
LoadRunbooksFromDirectory(config.Envs.EPCC_RUNBOOK_DIRECTORY)
if loadedRunbookCount := LoadRunbooksFromDirectory(config.Envs.EPCC_RUNBOOK_DIRECTORY); loadedRunbookCount == 0 {
log.Warnf("EPCC_RUNBOOK_DIRECTORY set as %s but no files found, runbooks should end in .epcc.yml", config.Envs.EPCC_RUNBOOK_DIRECTORY)
}
}

}

func LoadRunbooksFromDirectory(dir string) {
func LoadRunbooksFromDirectory(dir string) uint32 {

entries, err := os.ReadDir(dir)
if err != nil {
log.Warnf("Could not read Runbooks from directory %s due to error: %v", dir, err)
return
return 0
}

count := uint32(0)
for _, entry := range entries {
info, err := entry.Info()
if err != nil {
Expand All @@ -95,11 +97,14 @@ func LoadRunbooksFromDirectory(dir string) {
log.Warnf("Could not read Runbooks from file %s due to error: %v", filename, err)
continue
}
count++
} else {
log.Tracef("File %s does not end in .epcc.yml, not parsing.", filename)
}

}

return count
}

func GetRunbookNames() []string {
Expand Down

0 comments on commit 015e4f2

Please sign in to comment.