From 5e85038d9c6fd92667bc94e93c023242753e1056 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 16 Sep 2025 22:14:12 -0400 Subject: [PATCH] feat: add PrintCommand support to all task executors --- plugins/common/exec.go | 5 ++++- plugins/common/plugn.go | 5 ++++- plugins/common/sftp.go | 2 +- plugins/common/ssh.go | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/common/exec.go b/plugins/common/exec.go index c5790ba6e..367449b8b 100644 --- a/plugins/common/exec.go +++ b/plugins/common/exec.go @@ -29,6 +29,9 @@ type ExecCommandInput struct { // Env is the environment variables to pass to the command Env map[string]string + // PrintCommand prints the command before executing + PrintCommand bool + // Stdin is the stdin of the command Stdin io.Reader @@ -141,7 +144,7 @@ func CallExecCommandWithContext(ctx context.Context, input ExecCommandInput) (Ex cmd.Cwd = input.WorkingDirectory } - if os.Getenv("DOKKU_TRACE") == "1" { + if input.PrintCommand || os.Getenv("DOKKU_TRACE") == "1" { argsSt := "" if len(cmd.Args) > 0 { argsSt = strings.Join(cmd.Args, " ") diff --git a/plugins/common/plugn.go b/plugins/common/plugn.go index 8ce905ac5..4acf58a21 100644 --- a/plugins/common/plugn.go +++ b/plugins/common/plugn.go @@ -19,6 +19,9 @@ type PlugnTriggerInput struct { // Env is the environment variables to pass to the trigger Env map[string]string + // PrintCommand prints the command before executing + PrintCommand bool + // Stdin is the stdin of the command Stdin io.Reader @@ -55,7 +58,7 @@ func CallPlugnTriggerWithContext(ctx context.Context, input PlugnTriggerInput) ( 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") { LogDebug(fmt.Sprintf("plugn trigger %s stderr: %s", input.Trigger, line)) } diff --git a/plugins/common/sftp.go b/plugins/common/sftp.go index 1d8ade339..2758ff4e3 100644 --- a/plugins/common/sftp.go +++ b/plugins/common/sftp.go @@ -219,7 +219,7 @@ func (task SftpCopyTask) Execute(ctx context.Context) (SftpCopyResult, error) { }, 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)) } diff --git a/plugins/common/ssh.go b/plugins/common/ssh.go index c23f63bc9..f823c75c3 100644 --- a/plugins/common/ssh.go +++ b/plugins/common/ssh.go @@ -203,6 +203,7 @@ type SshTask struct { // PrintCommand prints the command before executing PrintCommand bool + // StreamStdio prints stdout and stderr directly to os.Stdout/err as // the command runs. StreamStdio bool @@ -334,7 +335,7 @@ func (task SshTask) Execute(ctx context.Context) (SshResult, error) { 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)) }