refactor: remove all calls to common.NewShellCmdWithArgs

This commit is contained in:
Jose Diaz-Gonzalez
2024-02-12 20:58:51 -05:00
parent 3c6cc68086
commit d8401a4d86
4 changed files with 76 additions and 56 deletions

View File

@@ -42,6 +42,12 @@ type ExecCommandInput struct {
// StreamStderr prints stderr directly to os.Stderr as the command runs.
StreamStderr bool
// StdoutWriter is the writer to write stdout to
StdoutWriter io.Writer
// StderrWriter is the writer to write stderr to
StderrWriter io.Writer
// Sudo runs the command with sudo -n -u root
Sudo bool
}
@@ -137,6 +143,12 @@ func CallExecCommandWithContext(ctx context.Context, input ExecCommandInput) (Ex
if input.StreamStderr {
cmd.StdErrWriter = os.Stderr
}
if input.StdoutWriter != nil {
cmd.StdOutWriter = input.StdoutWriter
}
if input.StderrWriter != nil {
cmd.StdErrWriter = input.StderrWriter
}
res, err := cmd.Execute(ctx)
if err != nil {