feat: add PrintCommand support to all task executors

This commit is contained in:
Jose Diaz-Gonzalez committed 2025-11-09 20:21:10 -05:00
1 parent b9025f6137
commit 5e85038d9c
4 files changed
+11 -4

No files matched your search

+4 -1
View File
@@ -29,6 +29,9 @@ type ExecCommandInput struct {
// Env is the environment variables to pass to the command // Env is the environment variables to pass to the command
Env map[string]string Env map[string]string
// PrintCommand prints the command before executing
PrintCommand bool
// Stdin is the stdin of the command // Stdin is the stdin of the command
Stdin io.Reader Stdin io.Reader
@@ -141,7 +144,7 @@ func CallExecCommandWithContext(ctx context.Context, input ExecCommandInput) (Ex
cmd.Cwd = input.WorkingDirectory cmd.Cwd = input.WorkingDirectory
} }
if os.Getenv("DOKKU_TRACE") == "1" { if input.PrintCommand || os.Getenv("DOKKU_TRACE") == "1" {
argsSt := "" argsSt := ""
if len(cmd.Args) > 0 { if len(cmd.Args) > 0 {
argsSt = strings.Join(cmd.Args, " ") argsSt = strings.Join(cmd.Args, " ")
+4 -1
View File
@@ -19,6 +19,9 @@ type PlugnTriggerInput struct {
// Env is the environment variables to pass to the trigger // Env is the environment variables to pass to the trigger
Env map[string]string Env map[string]string
// PrintCommand prints the command before executing
PrintCommand bool
// Stdin is the stdin of the command // Stdin is the stdin of the command
Stdin io.Reader Stdin io.Reader
@@ -55,7 +58,7 @@ func CallPlugnTriggerWithContext(ctx context.Context, input PlugnTriggerInput) (
StreamStderr: input.StreamStderr, StreamStderr: input.StreamStderr,
}) })
if os.Getenv("DOKKU_TRACE") == "1" { if input.PrintCommand || os.Getenv("DOKKU_TRACE") == "1" {
for _, line := range strings.Split(result.Stderr, "\n") { for _, line := range strings.Split(result.Stderr, "\n") {
LogDebug(fmt.Sprintf("plugn trigger %s stderr: %s", input.Trigger, line)) LogDebug(fmt.Sprintf("plugn trigger %s stderr: %s", input.Trigger, line))
} }
+1 -1
View File
@@ -219,7 +219,7 @@ func (task SftpCopyTask) Execute(ctx context.Context) (SftpCopyResult, error) {
}, ctx.Err() }, ctx.Err()
} }
if task.PrintCommand { if task.PrintCommand || os.Getenv("DOKKU_TRACE") == "1" {
LogDebug(fmt.Sprintf("ssh %s@%s cp %s %v", task.Username, task.Hostname, task.SourcePath, task.DestinationPath)) LogDebug(fmt.Sprintf("ssh %s@%s cp %s %v", task.Username, task.Hostname, task.SourcePath, task.DestinationPath))
} }
+2 -1
View File
@@ -203,6 +203,7 @@ type SshTask struct {
// PrintCommand prints the command before executing // PrintCommand prints the command before executing
PrintCommand bool PrintCommand bool
// StreamStdio prints stdout and stderr directly to os.Stdout/err as // StreamStdio prints stdout and stderr directly to os.Stdout/err as
// the command runs. // the command runs.
StreamStdio bool StreamStdio bool
@@ -334,7 +335,7 @@ func (task SshTask) Execute(ctx context.Context) (SshResult, error) {
command = "sudo" command = "sudo"
} }
if task.PrintCommand { if task.PrintCommand || os.Getenv("DOKKU_TRACE") == "1" {
LogDebug(fmt.Sprintf("ssh %s@%s %s %v", task.Username, task.Hostname, command, commandArgs)) LogDebug(fmt.Sprintf("ssh %s@%s %s %v", task.Username, task.Hostname, command, commandArgs))
} }