Skip to content

Commit 3540796

Browse files
authored
support digger planfile (#1977)
* support digger planfile
1 parent 567d04f commit 3540796

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

docs/ce/howto/custom-commands.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Digger makes the following environment variables available to custom commands:
2626
- `$DIGGER_OUT`
2727
- `$PR_BRANCH`
2828
- `$PROJECT_NAME`
29+
- `$DIGGER_PLANFILE` (the path where terraform plan file should be written)
2930

3031
These can be used to achieve workflows like [infracost diff](/ce/howto/using-infracost)
3132

libs/execution/execution.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ func (d DiggerExecutor) Plan() (*iac_utils.IacSummary, bool, bool, string, strin
285285
slog.Info("Running command",
286286
"command", step.Value,
287287
"project", d.ProjectNamespace+"#"+d.ProjectName)
288+
// setting additional env vars for run step
289+
if d.RunEnvVars == nil {
290+
d.RunEnvVars = make(map[string]string)
291+
}
292+
slog.Debug("adding plan file path to environment", "DIGGER_PLANFILE", d.PlanPathProvider.LocalPlanFilePath())
293+
d.RunEnvVars["DIGGER_PLANFILE"] = d.PlanPathProvider.LocalPlanFilePath()
288294
_, _, err := d.CommandRunner.Run(d.ProjectPath, step.Shell, commands, d.RunEnvVars)
289295
if err != nil {
290296
return nil, false, false, "", "", fmt.Errorf("error running command: %v", err)

0 commit comments

Comments
 (0)