Skip to content

Commit

Permalink
feat: log the template-rendered script content for debugging
Browse files Browse the repository at this point in the history
It's quite helpful when troubleshooting a template to be able to see
what the actual rendered output is -- this logs it alongside the
stdout/stderr for a script
  • Loading branch information
tjhop committed May 23, 2024
1 parent 7b78868 commit 93fc103
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func Run(ctx context.Context, runID ulid.ULID, path, content string, allVars []s
}
defer stderrLog.Close()

// log script content itself for testing template rendering
if err := os.WriteFile(filepath.Join(logDir, "script.mango-rendered"), []byte(content), 0644); err != nil {
return fmt.Errorf("Failed to write rendered script to log file: %v", err)
}

// runtime dir prep
workDir := filepath.Join(viper.GetString("mango.temp-dir"), runID.String())
if err := os.MkdirAll(workDir, 0750); err != nil && !os.IsExist(err) {
Expand Down

0 comments on commit 93fc103

Please sign in to comment.