Skip to content

Commit 015e4f2

Browse files
authored
Resolves #304 - Add warning if EPCC runbook directory is not found (#305)
1 parent 435db1e commit 015e4f2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

external/runbooks/runbooks.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,21 @@ func init() {
5858
func InitializeBuiltInRunbooks() {
5959
LoadBuiltInRunbooks(embeddedRunbooks)
6060
if config.Envs.EPCC_RUNBOOK_DIRECTORY != "" {
61-
LoadRunbooksFromDirectory(config.Envs.EPCC_RUNBOOK_DIRECTORY)
61+
if loadedRunbookCount := LoadRunbooksFromDirectory(config.Envs.EPCC_RUNBOOK_DIRECTORY); loadedRunbookCount == 0 {
62+
log.Warnf("EPCC_RUNBOOK_DIRECTORY set as %s but no files found, runbooks should end in .epcc.yml", config.Envs.EPCC_RUNBOOK_DIRECTORY)
63+
}
6264
}
63-
6465
}
6566

66-
func LoadRunbooksFromDirectory(dir string) {
67+
func LoadRunbooksFromDirectory(dir string) uint32 {
6768

6869
entries, err := os.ReadDir(dir)
6970
if err != nil {
7071
log.Warnf("Could not read Runbooks from directory %s due to error: %v", dir, err)
71-
return
72+
return 0
7273
}
7374

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

102105
}
106+
107+
return count
103108
}
104109

105110
func GetRunbookNames() []string {

0 commit comments

Comments
 (0)