From b3c0f9e93bbc082551e9d7c014e5667dbde4bd3c Mon Sep 17 00:00:00 2001 From: Steve Ramage Date: Mon, 8 Jan 2024 08:48:00 -0800 Subject: [PATCH] Resolves #439 - Add support for other embedded runbooks --- external/runbooks/runbooks.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/external/runbooks/runbooks.go b/external/runbooks/runbooks.go index 32c185a..afd66d3 100644 --- a/external/runbooks/runbooks.go +++ b/external/runbooks/runbooks.go @@ -17,6 +17,8 @@ var embeddedRunbooks embed.FS var runbooks map[string]Runbook +var otherEmbeddedRunbooks []embed.FS + type Runbook struct { // The name of the runbook @@ -61,6 +63,13 @@ func Reset() { func InitializeBuiltInRunbooks() { LoadBuiltInRunbooks(embeddedRunbooks) + + log.Tracef("Processing other embedded runbooks") + + for _, fs := range otherEmbeddedRunbooks { + LoadBuiltInRunbooks(fs) + } + env := config.GetEnv() if env.EPCC_RUNBOOK_DIRECTORY != "" { if loadedRunbookCount := LoadRunbooksFromDirectory(env.EPCC_RUNBOOK_DIRECTORY); loadedRunbookCount == 0 { @@ -69,6 +78,10 @@ func InitializeBuiltInRunbooks() { } } +func AddOtherEmbeddedRunbooks(fs embed.FS) { + otherEmbeddedRunbooks = append(otherEmbeddedRunbooks, fs) +} + func LoadRunbooksFromDirectory(dir string) uint32 { entries, err := os.ReadDir(dir)