Skip to content

Commit 55e9c57

Browse files
committed
chore: venv update
1 parent ba4b753 commit 55e9c57

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

internal/shell/run_cmd.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ const SignalForwardingDelay = time.Second * 15
3333

3434
// ShellOptions contains the configuration needed to run shell commands.
3535
type ShellOptions struct {
36-
Writers writer.Writers
37-
EngineOptions *engine.EngineOptions
38-
EngineConfig *engine.EngineConfig
39-
Telemetry *telemetry.Options
40-
Env map[string]string
41-
Exec vexec.Exec
36+
Writers writer.Writers
37+
EngineOptions *engine.EngineOptions
38+
EngineConfig *engine.EngineConfig
39+
Telemetry *telemetry.Options
40+
Env map[string]string
41+
Exec vexec.Exec
42+
4243
RootWorkingDir string
4344
WorkingDir string
4445
TFPath string
@@ -153,8 +154,7 @@ func (o *ShellOptions) WithForwardTFStdout(f bool) *ShellOptions {
153154
return o
154155
}
155156

156-
// WithExec installs a vexec.Exec backend that replaces the default os/exec
157-
// path used by RunCommandWithOutput. Pass nil to clear it. Intended for tests.
157+
// WithExec sets the vexec.Exec used by RunCommandWithOutput.
158158
func (o *ShellOptions) WithExec(e vexec.Exec) *ShellOptions {
159159
o.Exec = e
160160

@@ -258,6 +258,10 @@ func RunCommandWithOutput(
258258
}
259259

260260
if runOpts.Exec != nil {
261+
if needsPTY {
262+
return errors.New("shell: vexec backend does not support PTY mode")
263+
}
264+
261265
injectedCmd := runOpts.Exec.Command(ctx, command, args...)
262266
injectedCmd.SetDir(commandDir)
263267
injectedCmd.SetEnv(util.EnvSliceFromMap(runOpts.Env))
@@ -305,6 +309,7 @@ func RunCommandWithOutput(
305309

306310
// procExecError builds a ProcessExecutionError using the standard fields from ShellOptions.
307311
// Pass nil for output when the failure occurred before any output was captured.
312+
// Caller guarantees a non-nil ShellOptions; the receiver is dereferenced unconditionally.
308313
func (o *ShellOptions) procExecError(err error, command, dir string, args []string, output *util.CmdOutput) error {
309314
pe := util.ProcessExecutionError{
310315
Err: err,

pkg/config/dependency.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/gruntwork-io/terragrunt/internal/shell"
4242
"github.com/gruntwork-io/terragrunt/internal/tf"
4343
"github.com/gruntwork-io/terragrunt/internal/util"
44+
"github.com/gruntwork-io/terragrunt/internal/vexec"
4445
"github.com/gruntwork-io/terragrunt/pkg/config/hclparse"
4546
)
4647

@@ -1449,6 +1450,11 @@ func runTerragruntOutputJSON(ctx context.Context, pctx *ParsingContext, l log.Lo
14491450

14501451
// shellRunOptsFromPctx builds a *shell.ShellOptions from ParsingContext flat fields.
14511452
func shellRunOptsFromPctx(pctx *ParsingContext) *shell.ShellOptions {
1453+
exec := pctx.Exec
1454+
if exec == nil {
1455+
exec = vexec.NewOSExec()
1456+
}
1457+
14521458
return shell.NewShellOptions().
14531459
WithWorkingDir(pctx.WorkingDir).
14541460
WithEnv(pctx.Env).
@@ -1460,7 +1466,7 @@ func shellRunOptsFromPctx(pctx *ParsingContext) *shell.ShellOptions {
14601466
WithExperiments(pctx.Experiments).
14611467
WithHeadless(pctx.Headless).
14621468
WithForwardTFStdout(pctx.ForwardTFStdout).
1463-
WithExec(pctx.Exec)
1469+
WithExec(exec)
14641470
}
14651471

14661472
// tfRunOptsFromPctx builds a *tf.RunOptions from ParsingContext flat fields.

pkg/config/parsing_context.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ type ParsingContext struct {
5353
Features *cty.Value
5454
Locals *cty.Value
5555

56-
// Exec, when non-nil, replaces the default os/exec backend used by run_cmd
57-
// and other shell-outs that read shell.ShellOptions from this context.
58-
// Intended for tests; production code leaves this nil.
5956
Exec vexec.Exec
6057

6158
Env map[string]string

0 commit comments

Comments
 (0)