-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] Adding methods to capture inter-step communication #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
8bdcb59
40fac5f
7d7b336
a9a8d84
f7f1902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ import ( | |
| "github.com/bmeg/sifter/task" | ||
| ) | ||
|
|
||
| func ExecuteFile(playFile string, workDir string, outDir string, inputs map[string]string) error { | ||
| func ExecuteFile(playFile string, workDir string, outDir string, inputs map[string]string, debugDir string, debugLimit int) error { | ||
| logger.Info("Starting", "playFile", playFile) | ||
| pb := playbook.Playbook{} | ||
| if err := playbook.ParseFile(playFile, &pb); err != nil { | ||
|
|
@@ -19,10 +19,10 @@ func ExecuteFile(playFile string, workDir string, outDir string, inputs map[stri | |
| a, _ := filepath.Abs(playFile) | ||
| baseDir := filepath.Dir(a) | ||
| logger.Debug("parsed file", "baseDir", baseDir, "playbook", pb) | ||
| return Execute(pb, baseDir, workDir, outDir, inputs) | ||
| return Execute(pb, baseDir, workDir, outDir, inputs, debugDir, debugLimit) | ||
| } | ||
|
|
||
| func Execute(pb playbook.Playbook, baseDir string, workDir string, outDir string, params map[string]string) error { | ||
| func Execute(pb playbook.Playbook, baseDir string, workDir string, outDir string, params map[string]string, debugDir string, debugLimit int) error { | ||
|
|
||
| if outDir == "" { | ||
| outDir = pb.GetDefaultOutDir() | ||
|
|
@@ -32,13 +32,31 @@ func Execute(pb playbook.Playbook, baseDir string, workDir string, outDir string | |
| os.MkdirAll(outDir, 0777) | ||
| } | ||
|
|
||
| // Setup debug capture directory if enabled | ||
| // Enable if: user explicitly set dir, OR user changed limit from default | ||
| enableDebug := debugDir != "" || (debugLimit != 10) | ||
| if enableDebug { | ||
| if debugDir == "" { | ||
| debugDir = filepath.Join(workDir, "debug-capture") | ||
| } else if !filepath.IsAbs(debugDir) { | ||
| debugDir = filepath.Join(workDir, debugDir) | ||
| } | ||
| if _, err := os.Stat(debugDir); os.IsNotExist(err) { | ||
| if err := os.MkdirAll(debugDir, 0777); err != nil { | ||
| logger.Error("Failed to create debug directory", "error", err) | ||
| return err | ||
| } | ||
| } | ||
|
||
| logger.Info("Debug capture enabled", "dir", debugDir, "limit", debugLimit) | ||
| } | ||
|
|
||
| nInputs, err := pb.PrepConfig(params, workDir) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| logger.Debug("Running", "outDir", outDir) | ||
|
|
||
| t := task.NewTask(pb.Name, baseDir, workDir, outDir, nInputs) | ||
| err = pb.Execute(t) | ||
| err = pb.Execute(t, debugDir, debugLimit) | ||
| return err | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New CLI options (
--capture-dir,--capture-limit) add behavior that isn’t covered by the existing command-line integration test (test/command_line_test.gorunssifter runwithout flags). Consider adding a test case that enables capture and asserts that the expected.ndjsonfiles are created (and respect the limit), to prevent regressions.