From 047a3c00f5e85b052febf6bb7b927e63e2b460df Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 12 Feb 2024 20:07:43 -0500 Subject: [PATCH 1/2] chore: remove default false values when calling CallExecCommand --- plugins/app-json/src/commands/commands.go | 1 - plugins/apps/src/commands/commands.go | 1 - plugins/builder/src/commands/commands.go | 1 - plugins/buildpacks/src/commands/commands.go | 1 - plugins/common/docker.go | 15 +++++---------- plugins/config/src/commands/commands.go | 1 - plugins/cron/src/commands/commands.go | 1 - plugins/logs/src/commands/commands.go | 1 - plugins/logs/triggers.go | 1 - plugins/network/functions.go | 2 -- plugins/network/src/commands/commands.go | 1 - plugins/ports/src/commands/commands.go | 1 - plugins/proxy/src/commands/commands.go | 1 - plugins/ps/src/commands/commands.go | 1 - plugins/ps/triggers.go | 1 - plugins/registry/functions.go | 14 ++++++-------- plugins/registry/src/commands/commands.go | 1 - plugins/registry/subcommands.go | 7 +++---- plugins/repo/src/commands/commands.go | 1 - plugins/resource/src/commands/commands.go | 1 - plugins/scheduler-k3s/functions.go | 2 -- plugins/scheduler-k3s/src/commands/commands.go | 1 - plugins/scheduler-k3s/triggers.go | 17 ++++++----------- plugins/scheduler/src/commands/commands.go | 1 - 24 files changed, 20 insertions(+), 55 deletions(-) diff --git a/plugins/app-json/src/commands/commands.go b/plugins/app-json/src/commands/commands.go index fc8874a7a..0b643b035 100644 --- a/plugins/app-json/src/commands/commands.go +++ b/plugins/app-json/src/commands/commands.go @@ -36,7 +36,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/apps/src/commands/commands.go b/plugins/apps/src/commands/commands.go index 2d121246a..ab7f3d40b 100644 --- a/plugins/apps/src/commands/commands.go +++ b/plugins/apps/src/commands/commands.go @@ -53,7 +53,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/builder/src/commands/commands.go b/plugins/builder/src/commands/commands.go index a4b0549dc..3d1c5a91a 100644 --- a/plugins/builder/src/commands/commands.go +++ b/plugins/builder/src/commands/commands.go @@ -36,7 +36,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/buildpacks/src/commands/commands.go b/plugins/buildpacks/src/commands/commands.go index d29b6e566..86217f9e5 100644 --- a/plugins/buildpacks/src/commands/commands.go +++ b/plugins/buildpacks/src/commands/commands.go @@ -41,7 +41,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/common/docker.go b/plugins/common/docker.go index fdc28022b..14916cfbe 100644 --- a/plugins/common/docker.go +++ b/plugins/common/docker.go @@ -21,10 +21,9 @@ func ContainerIsRunning(containerID string) bool { // ContainerRemove runs 'docker container remove' against an existing container func ContainerRemove(containerID string) bool { result, err := CallExecCommand(ExecCommandInput{ - Command: DockerBin(), - Args: []string{"container", "remove", "-f", containerID}, - CaptureOutput: false, - StreamStdio: false, + Command: DockerBin(), + Args: []string{"container", "remove", "-f", containerID}, + StreamStderr: true, }) if err != nil { return false @@ -35,10 +34,8 @@ func ContainerRemove(containerID string) bool { // ContainerExists checks to see if a container exists func ContainerExists(containerID string) bool { result, err := CallExecCommand(ExecCommandInput{ - Command: DockerBin(), - Args: []string{"container", "inspect", containerID}, - CaptureOutput: false, - StreamStdio: false, + Command: DockerBin(), + Args: []string{"container", "inspect", containerID}, }) if err != nil { return false @@ -138,7 +135,6 @@ func CopyFromImage(appName string, image string, source string, destination stri Command: "tail", Args: []string{"-c1", destination}, CaptureOutput: true, - StreamStdio: false, }) if err != nil || result.ExitCode != 0 { return fmt.Errorf("Unable to append trailing newline to copied file: %v", result.Stderr) @@ -250,7 +246,6 @@ func DockerInspect(containerOrImageID, format string) (output string, err error) Command: DockerBin(), Args: []string{"inspect", "--format", format, containerOrImageID}, CaptureOutput: true, - StreamStdio: false, }) if err != nil { return "", err diff --git a/plugins/config/src/commands/commands.go b/plugins/config/src/commands/commands.go index 53bc00db8..34a37ffd5 100644 --- a/plugins/config/src/commands/commands.go +++ b/plugins/config/src/commands/commands.go @@ -57,7 +57,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/cron/src/commands/commands.go b/plugins/cron/src/commands/commands.go index c648c35b4..9125a9384 100644 --- a/plugins/cron/src/commands/commands.go +++ b/plugins/cron/src/commands/commands.go @@ -37,7 +37,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/logs/src/commands/commands.go b/plugins/logs/src/commands/commands.go index afa4f93f3..5da6bddbd 100644 --- a/plugins/logs/src/commands/commands.go +++ b/plugins/logs/src/commands/commands.go @@ -63,7 +63,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/logs/triggers.go b/plugins/logs/triggers.go index af8c32ca2..1a2084e54 100644 --- a/plugins/logs/triggers.go +++ b/plugins/logs/triggers.go @@ -49,7 +49,6 @@ func TriggerDockerArgsProcessDeploy(appName string) error { Command: common.DockerBin(), Args: []string{"system", "info", "--format", "{{ .LoggingDriver }}"}, CaptureOutput: true, - StreamStdio: false, }) if !allowedDrivers[result.StdoutContents()] { diff --git a/plugins/network/functions.go b/plugins/network/functions.go index 447ecdaaf..fa8abaec5 100644 --- a/plugins/network/functions.go +++ b/plugins/network/functions.go @@ -62,7 +62,6 @@ func isContainerInNetwork(containerID string, networkName string) bool { Command: common.DockerBin(), Args: []string{"container", "inspect", "--format", "{{range $net, $v := .NetworkSettings.Networks}}{{println $net}}{{end}}", containerID}, CaptureOutput: true, - StreamStdio: false, }) if err != nil { @@ -133,7 +132,6 @@ func listNetworks() ([]string, error) { Command: common.DockerBin(), Args: []string{"network", "ls", "--format", "{{ .Name }}"}, CaptureOutput: true, - StreamStdio: false, }) if err != nil { common.LogVerboseQuiet(result.StderrContents()) diff --git a/plugins/network/src/commands/commands.go b/plugins/network/src/commands/commands.go index 66c285698..f44f4e378 100644 --- a/plugins/network/src/commands/commands.go +++ b/plugins/network/src/commands/commands.go @@ -43,7 +43,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/ports/src/commands/commands.go b/plugins/ports/src/commands/commands.go index 68c7460e4..82a22d1e9 100644 --- a/plugins/ports/src/commands/commands.go +++ b/plugins/ports/src/commands/commands.go @@ -40,7 +40,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/proxy/src/commands/commands.go b/plugins/proxy/src/commands/commands.go index 93ffc4f62..fd9f0bb8e 100644 --- a/plugins/proxy/src/commands/commands.go +++ b/plugins/proxy/src/commands/commands.go @@ -40,7 +40,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/ps/src/commands/commands.go b/plugins/ps/src/commands/commands.go index 9f73c76d8..a0e1f4f15 100644 --- a/plugins/ps/src/commands/commands.go +++ b/plugins/ps/src/commands/commands.go @@ -43,7 +43,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index 5841415ec..50d57f554 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -106,7 +106,6 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error { Command: "procfile-util", Args: []string{"check", "-P", processSpecificProcfile}, CaptureOutput: true, - StreamStdio: false, }) if err != nil { return fmt.Errorf(result.StderrContents()) diff --git a/plugins/registry/functions.go b/plugins/registry/functions.go index 053713e8b..d965486ee 100644 --- a/plugins/registry/functions.go +++ b/plugins/registry/functions.go @@ -124,20 +124,18 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e func dockerTag(imageID string, imageTag string) bool { result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: common.DockerBin(), - Args: []string{"image", "tag", imageID, imageTag}, - CaptureOutput: false, - StreamStdio: true, + Command: common.DockerBin(), + Args: []string{"image", "tag", imageID, imageTag}, + StreamStdio: true, }) return err == nil && result.ExitCode == 0 } func dockerPush(imageTag string) bool { result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: common.DockerBin(), - Args: []string{"image", "push", imageTag}, - CaptureOutput: false, - StreamStdio: true, + Command: common.DockerBin(), + Args: []string{"image", "push", imageTag}, + StreamStdio: true, }) return err == nil && result.ExitCode == 0 } diff --git a/plugins/registry/src/commands/commands.go b/plugins/registry/src/commands/commands.go index 6b7ac8709..6dd19cd19 100644 --- a/plugins/registry/src/commands/commands.go +++ b/plugins/registry/src/commands/commands.go @@ -37,7 +37,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/registry/subcommands.go b/plugins/registry/subcommands.go index 2a5c58296..34cf076f6 100644 --- a/plugins/registry/subcommands.go +++ b/plugins/registry/subcommands.go @@ -54,10 +54,9 @@ func CommandLogin(server string, username string, password string, passwordStdin } _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ - Trigger: "post-registry-login", - Args: []string{server, username}, - StreamStdio: true, - CaptureOutput: false, + Trigger: "post-registry-login", + Args: []string{server, username}, + StreamStdio: true, Env: map[string]string{ "DOCKER_REGISTRY_PASS": password, }, diff --git a/plugins/repo/src/commands/commands.go b/plugins/repo/src/commands/commands.go index 2fb6b5ac6..80b83357b 100644 --- a/plugins/repo/src/commands/commands.go +++ b/plugins/repo/src/commands/commands.go @@ -36,7 +36,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/resource/src/commands/commands.go b/plugins/resource/src/commands/commands.go index 801cd1d04..d79c4c539 100644 --- a/plugins/resource/src/commands/commands.go +++ b/plugins/resource/src/commands/commands.go @@ -39,7 +39,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/scheduler-k3s/functions.go b/plugins/scheduler-k3s/functions.go index 90b6e617e..959bc2aa5 100644 --- a/plugins/scheduler-k3s/functions.go +++ b/plugins/scheduler-k3s/functions.go @@ -338,7 +338,6 @@ func extractStartCommand(input StartCommandInput) string { Trigger: "config-get", Args: []string{input.AppName, "DOKKU_START_CMD"}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && resp.ExitCode == 0 && len(resp.Stdout) > 0 { command = strings.TrimSpace(resp.Stdout) @@ -349,7 +348,6 @@ func extractStartCommand(input StartCommandInput) string { Trigger: "config-get", Args: []string{input.AppName, "DOKKU_DOCKERFILE_START_CMD"}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && resp.ExitCode == 0 && len(resp.Stdout) > 0 { command = strings.TrimSpace(resp.Stdout) diff --git a/plugins/scheduler-k3s/src/commands/commands.go b/plugins/scheduler-k3s/src/commands/commands.go index e94890d76..58e927414 100644 --- a/plugins/scheduler-k3s/src/commands/commands.go +++ b/plugins/scheduler-k3s/src/commands/commands.go @@ -46,7 +46,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/scheduler-k3s/triggers.go b/plugins/scheduler-k3s/triggers.go index 3ff7a52ab..68dc7d447 100644 --- a/plugins/scheduler-k3s/triggers.go +++ b/plugins/scheduler-k3s/triggers.go @@ -531,20 +531,18 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e common.LogInfo1("Running post-deploy") _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ - Args: []string{appName, "", "", imageTag}, - CaptureOutput: false, - StreamStdio: true, - Trigger: "core-post-deploy", + Args: []string{appName, "", "", imageTag}, + StreamStdio: true, + Trigger: "core-post-deploy", }) if err != nil { return fmt.Errorf("Error running core-post-deploy: %w", err) } _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ - Args: []string{appName, "", "", imageTag}, - CaptureOutput: false, - StreamStdio: true, - Trigger: "post-deploy", + Args: []string{appName, "", "", imageTag}, + StreamStdio: true, + Trigger: "post-deploy", }) if err != nil { return fmt.Errorf("Error running post-deploy: %w", err) @@ -806,14 +804,12 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args [] Trigger: "config-get", Args: []string{appName, "DOKKU_RM_CONTAINER"}, CaptureOutput: true, - StreamStdio: false, }) if err != nil { resp, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ Trigger: "config-get-global", Args: []string{"DOKKU_RM_CONTAINER"}, CaptureOutput: true, - StreamStdio: false, }) if err == nil { dokkuRmContainer = strings.TrimSpace(resp.Stdout) @@ -865,7 +861,6 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args [] Trigger: "procfile-get-command", Args: []string{appName, args[0], "5000"}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && resp.Stdout != "" { common.LogInfo1Quiet(fmt.Sprintf("Found '%s' in Procfile, running that command", args[0])) diff --git a/plugins/scheduler/src/commands/commands.go b/plugins/scheduler/src/commands/commands.go index 4cde898ef..645326b97 100644 --- a/plugins/scheduler/src/commands/commands.go +++ b/plugins/scheduler/src/commands/commands.go @@ -36,7 +36,6 @@ func main() { Command: "ps", Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, CaptureOutput: true, - StreamStdio: false, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) From 3c6cc68086475be9dac9253b57289cc3d654f29f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 12 Feb 2024 20:28:31 -0500 Subject: [PATCH 2/2] refactor: capture output by default This is almost certainly the correct default for Dokku. While it's a BC break and might cause an increase in memory usage, the api is mostly internal and therefore this is safe to use. --- plugins/app-json/src/commands/commands.go | 5 ++--- plugins/apps/src/commands/commands.go | 5 ++--- plugins/builder/src/commands/commands.go | 5 ++--- plugins/buildpacks/src/commands/commands.go | 5 ++--- plugins/common/docker.go | 15 ++++++-------- plugins/common/exec.go | 8 ++++---- plugins/common/plugn.go | 20 +++++++++---------- plugins/common/ssh.go | 6 +++--- plugins/config/src/commands/commands.go | 5 ++--- plugins/cron/src/commands/commands.go | 5 ++--- plugins/logs/functions.go | 3 +-- plugins/logs/src/commands/commands.go | 5 ++--- plugins/logs/triggers.go | 5 ++--- plugins/network/functions.go | 10 ++++------ plugins/network/src/commands/commands.go | 5 ++--- plugins/ports/src/commands/commands.go | 5 ++--- plugins/proxy/src/commands/commands.go | 5 ++--- plugins/ps/src/commands/commands.go | 5 ++--- plugins/ps/triggers.go | 5 ++--- plugins/registry/src/commands/commands.go | 5 ++--- plugins/repo/src/commands/commands.go | 5 ++--- plugins/resource/src/commands/commands.go | 5 ++--- plugins/scheduler-k3s/functions.go | 10 ++++------ .../scheduler-k3s/src/commands/commands.go | 5 ++--- plugins/scheduler-k3s/subcommands.go | 5 +---- plugins/scheduler-k3s/triggers.go | 15 ++++++-------- plugins/scheduler/src/commands/commands.go | 5 ++--- 27 files changed, 75 insertions(+), 107 deletions(-) diff --git a/plugins/app-json/src/commands/commands.go b/plugins/app-json/src/commands/commands.go index 0b643b035..0d23096e2 100644 --- a/plugins/app-json/src/commands/commands.go +++ b/plugins/app-json/src/commands/commands.go @@ -33,9 +33,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/apps/src/commands/commands.go b/plugins/apps/src/commands/commands.go index ab7f3d40b..de1471a56 100644 --- a/plugins/apps/src/commands/commands.go +++ b/plugins/apps/src/commands/commands.go @@ -50,9 +50,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/builder/src/commands/commands.go b/plugins/builder/src/commands/commands.go index 3d1c5a91a..d923fae9a 100644 --- a/plugins/builder/src/commands/commands.go +++ b/plugins/builder/src/commands/commands.go @@ -33,9 +33,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/buildpacks/src/commands/commands.go b/plugins/buildpacks/src/commands/commands.go index 86217f9e5..052900b12 100644 --- a/plugins/buildpacks/src/commands/commands.go +++ b/plugins/buildpacks/src/commands/commands.go @@ -38,9 +38,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/common/docker.go b/plugins/common/docker.go index 14916cfbe..354bb2405 100644 --- a/plugins/common/docker.go +++ b/plugins/common/docker.go @@ -132,9 +132,8 @@ func CopyFromImage(appName string, image string, source string, destination stri // add trailing newline for certain places where file parsing depends on it result, err := CallExecCommand(ExecCommandInput{ - Command: "tail", - Args: []string{"-c1", destination}, - CaptureOutput: true, + Command: "tail", + Args: []string{"-c1", destination}, }) if err != nil || result.ExitCode != 0 { return fmt.Errorf("Unable to append trailing newline to copied file: %v", result.Stderr) @@ -243,9 +242,8 @@ func DockerContainerCreate(image string, containerCreateArgs []string) (string, // DockerInspect runs an inspect command with a given format against a container or image ID func DockerInspect(containerOrImageID, format string) (output string, err error) { result, err := CallExecCommand(ExecCommandInput{ - Command: DockerBin(), - Args: []string{"inspect", "--format", format, containerOrImageID}, - CaptureOutput: true, + Command: DockerBin(), + Args: []string{"inspect", "--format", format, containerOrImageID}, }) if err != nil { return "", err @@ -272,9 +270,8 @@ func GetWorkingDir(appName string, image string) string { func IsComposeInstalled() bool { result, err := CallExecCommand(ExecCommandInput{ - Command: DockerBin(), - Args: []string{"info", "--format", "{{range .ClientInfo.Plugins}}{{if eq .Name \"compose\"}}true{{end}}{{end}}')"}, - CaptureOutput: true, + Command: DockerBin(), + Args: []string{"info", "--format", "{{range .ClientInfo.Plugins}}{{if eq .Name \"compose\"}}true{{end}}{{end}}')"}, }) return err == nil && result.ExitCode == 0 } diff --git a/plugins/common/exec.go b/plugins/common/exec.go index ac8e6bb98..c114f1d86 100644 --- a/plugins/common/exec.go +++ b/plugins/common/exec.go @@ -23,8 +23,8 @@ type ExecCommandInput struct { // Args are the arguments to pass to the command Args []string - // CaptureOutput determines whether to capture the output of the command - CaptureOutput bool + // DisableStdioBuffer disables the stdio buffer + DisableStdioBuffer bool // Env is the environment variables to pass to the command Env map[string]string @@ -95,7 +95,7 @@ func CallExecCommandWithContext(ctx context.Context, input ExecCommandInput) (Ex // being captured, then color output can be forced. isatty := !color.NoColor env := os.Environ() - if isatty && !input.CaptureOutput { + if isatty && input.DisableStdioBuffer { env = append(env, "FORCE_TTY=1") } if input.Env != nil { @@ -115,7 +115,7 @@ func CallExecCommandWithContext(ctx context.Context, input ExecCommandInput) (Ex Command: command, Args: commandArgs, Env: env, - DisableStdioBuffer: !input.CaptureOutput, + DisableStdioBuffer: input.DisableStdioBuffer, } if os.Getenv("DOKKU_TRACE") == "1" { diff --git a/plugins/common/plugn.go b/plugins/common/plugn.go index 2c1a98cb8..422dbfba3 100644 --- a/plugins/common/plugn.go +++ b/plugins/common/plugn.go @@ -10,8 +10,8 @@ type PlugnTriggerInput struct { // Args are the arguments to pass to the trigger Args []string - // CaptureOutput determines whether to capture the output of the trigger - CaptureOutput bool + // DisableStdioBuffer disables the stdio buffer + DisableStdioBuffer bool // Env is the environment variables to pass to the trigger Env map[string]string @@ -42,13 +42,13 @@ func CallPlugnTriggerWithContext(ctx context.Context, input PlugnTriggerInput) ( args := []string{"trigger", input.Trigger} args = append(args, input.Args...) return CallExecCommandWithContext(ctx, ExecCommandInput{ - Command: "plugn", - Args: args, - CaptureOutput: input.CaptureOutput, - Env: input.Env, - Stdin: input.Stdin, - StreamStdio: input.StreamStdio, - StreamStdout: input.StreamStdout, - StreamStderr: input.StreamStderr, + Command: "plugn", + Args: args, + DisableStdioBuffer: input.DisableStdioBuffer, + Env: input.Env, + Stdin: input.Stdin, + StreamStdio: input.StreamStdio, + StreamStdout: input.StreamStdout, + StreamStderr: input.StreamStderr, }) } diff --git a/plugins/common/ssh.go b/plugins/common/ssh.go index 458b32b66..33e477b66 100644 --- a/plugins/common/ssh.go +++ b/plugins/common/ssh.go @@ -31,8 +31,8 @@ type SshCommandInput struct { // Args are the arguments to pass to the command. Args []string - // CaptureOutput saves any output from in the TaskResult - CaptureOutput bool + // DisableStdioBuffer disables the stdio buffer + DisableStdioBuffer bool // Env is a list of environment variables to add to the current environment Env map[string]string @@ -137,7 +137,7 @@ func CallSshCommandWithContext(ctx context.Context, input SshCommandInput) (SshR Command: input.Command, Args: input.Args, Env: env, - DisableStdioBuffer: !input.CaptureOutput, + DisableStdioBuffer: input.DisableStdioBuffer, AllowUknownHosts: input.AllowUknownHosts, Hostname: u.Hostname(), Port: uint(port), diff --git a/plugins/config/src/commands/commands.go b/plugins/config/src/commands/commands.go index 34a37ffd5..541b967eb 100644 --- a/plugins/config/src/commands/commands.go +++ b/plugins/config/src/commands/commands.go @@ -54,9 +54,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/cron/src/commands/commands.go b/plugins/cron/src/commands/commands.go index 9125a9384..a88f391c7 100644 --- a/plugins/cron/src/commands/commands.go +++ b/plugins/cron/src/commands/commands.go @@ -34,9 +34,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/logs/functions.go b/plugins/logs/functions.go index 9d55c3374..d6ecf5e75 100644 --- a/plugins/logs/functions.go +++ b/plugins/logs/functions.go @@ -38,8 +38,7 @@ const vectorOldContainerName = "vector" func getComposeFile() ([]byte, error) { result, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ - Trigger: "vector-template-source", - CaptureOutput: true, + Trigger: "vector-template-source", }) if err == nil && result.ExitCode == 0 && strings.TrimSpace(result.Stdout) != "" { contents, err := os.ReadFile(strings.TrimSpace(result.Stdout)) diff --git a/plugins/logs/src/commands/commands.go b/plugins/logs/src/commands/commands.go index 5da6bddbd..4df696869 100644 --- a/plugins/logs/src/commands/commands.go +++ b/plugins/logs/src/commands/commands.go @@ -60,9 +60,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/logs/triggers.go b/plugins/logs/triggers.go index 1a2084e54..c0d35ea8a 100644 --- a/plugins/logs/triggers.go +++ b/plugins/logs/triggers.go @@ -46,9 +46,8 @@ func TriggerDockerArgsProcessDeploy(appName string) error { if !hasDriverOpt { result, _ := common.CallExecCommand(common.ExecCommandInput{ - Command: common.DockerBin(), - Args: []string{"system", "info", "--format", "{{ .LoggingDriver }}"}, - CaptureOutput: true, + Command: common.DockerBin(), + Args: []string{"system", "info", "--format", "{{ .LoggingDriver }}"}, }) if !allowedDrivers[result.StdoutContents()] { diff --git a/plugins/network/functions.go b/plugins/network/functions.go index fa8abaec5..a39b5fd5a 100644 --- a/plugins/network/functions.go +++ b/plugins/network/functions.go @@ -59,9 +59,8 @@ func attachAppToNetwork(containerID string, networkName string, appName string, // isContainerInNetwork returns true if the container is already attached to the specified network func isContainerInNetwork(containerID string, networkName string) bool { result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: common.DockerBin(), - Args: []string{"container", "inspect", "--format", "{{range $net, $v := .NetworkSettings.Networks}}{{println $net}}{{end}}", containerID}, - CaptureOutput: true, + Command: common.DockerBin(), + Args: []string{"container", "inspect", "--format", "{{range $net, $v := .NetworkSettings.Networks}}{{println $net}}{{end}}", containerID}, }) if err != nil { @@ -129,9 +128,8 @@ func networkExists(networkName string) (bool, error) { // listNetworks returns a list of docker networks func listNetworks() ([]string, error) { result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: common.DockerBin(), - Args: []string{"network", "ls", "--format", "{{ .Name }}"}, - CaptureOutput: true, + Command: common.DockerBin(), + Args: []string{"network", "ls", "--format", "{{ .Name }}"}, }) if err != nil { common.LogVerboseQuiet(result.StderrContents()) diff --git a/plugins/network/src/commands/commands.go b/plugins/network/src/commands/commands.go index f44f4e378..d2d725c4e 100644 --- a/plugins/network/src/commands/commands.go +++ b/plugins/network/src/commands/commands.go @@ -40,9 +40,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/ports/src/commands/commands.go b/plugins/ports/src/commands/commands.go index 82a22d1e9..c82bfae23 100644 --- a/plugins/ports/src/commands/commands.go +++ b/plugins/ports/src/commands/commands.go @@ -37,9 +37,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/proxy/src/commands/commands.go b/plugins/proxy/src/commands/commands.go index fd9f0bb8e..f78c79b1f 100644 --- a/plugins/proxy/src/commands/commands.go +++ b/plugins/proxy/src/commands/commands.go @@ -37,9 +37,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/ps/src/commands/commands.go b/plugins/ps/src/commands/commands.go index a0e1f4f15..98a0c830d 100644 --- a/plugins/ps/src/commands/commands.go +++ b/plugins/ps/src/commands/commands.go @@ -40,9 +40,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index 50d57f554..c91b6c67f 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -103,9 +103,8 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error { } result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "procfile-util", - Args: []string{"check", "-P", processSpecificProcfile}, - CaptureOutput: true, + Command: "procfile-util", + Args: []string{"check", "-P", processSpecificProcfile}, }) if err != nil { return fmt.Errorf(result.StderrContents()) diff --git a/plugins/registry/src/commands/commands.go b/plugins/registry/src/commands/commands.go index 6dd19cd19..0742a61c4 100644 --- a/plugins/registry/src/commands/commands.go +++ b/plugins/registry/src/commands/commands.go @@ -34,9 +34,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/repo/src/commands/commands.go b/plugins/repo/src/commands/commands.go index 80b83357b..39dde24af 100644 --- a/plugins/repo/src/commands/commands.go +++ b/plugins/repo/src/commands/commands.go @@ -33,9 +33,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/resource/src/commands/commands.go b/plugins/resource/src/commands/commands.go index d79c4c539..47894a508 100644 --- a/plugins/resource/src/commands/commands.go +++ b/plugins/resource/src/commands/commands.go @@ -36,9 +36,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/scheduler-k3s/functions.go b/plugins/scheduler-k3s/functions.go index 959bc2aa5..287dcd75b 100644 --- a/plugins/scheduler-k3s/functions.go +++ b/plugins/scheduler-k3s/functions.go @@ -335,9 +335,8 @@ func extractStartCommand(input StartCommandInput) string { } resp, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ - Trigger: "config-get", - Args: []string{input.AppName, "DOKKU_START_CMD"}, - CaptureOutput: true, + Trigger: "config-get", + Args: []string{input.AppName, "DOKKU_START_CMD"}, }) if err == nil && resp.ExitCode == 0 && len(resp.Stdout) > 0 { command = strings.TrimSpace(resp.Stdout) @@ -345,9 +344,8 @@ func extractStartCommand(input StartCommandInput) string { if input.ImageSourceType == "dockerfile" { resp, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ - Trigger: "config-get", - Args: []string{input.AppName, "DOKKU_DOCKERFILE_START_CMD"}, - CaptureOutput: true, + Trigger: "config-get", + Args: []string{input.AppName, "DOKKU_DOCKERFILE_START_CMD"}, }) if err == nil && resp.ExitCode == 0 && len(resp.Stdout) > 0 { command = strings.TrimSpace(resp.Stdout) diff --git a/plugins/scheduler-k3s/src/commands/commands.go b/plugins/scheduler-k3s/src/commands/commands.go index 58e927414..b62fd0af9 100644 --- a/plugins/scheduler-k3s/src/commands/commands.go +++ b/plugins/scheduler-k3s/src/commands/commands.go @@ -43,9 +43,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent) diff --git a/plugins/scheduler-k3s/subcommands.go b/plugins/scheduler-k3s/subcommands.go index 5e5bd930e..594c938eb 100644 --- a/plugins/scheduler-k3s/subcommands.go +++ b/plugins/scheduler-k3s/subcommands.go @@ -356,10 +356,7 @@ func CommandClusterAdd(role string, remoteHost string, serverIP string, allowUkn k3sVersionCmd, err := common.CallExecCommand(common.ExecCommandInput{ Command: "k3s", - Args: []string{ - "--version", - }, - CaptureOutput: true, + Args: []string{"--version"}, }) if err != nil { return fmt.Errorf("Unable to call k3s version command: %w", err) diff --git a/plugins/scheduler-k3s/triggers.go b/plugins/scheduler-k3s/triggers.go index 68dc7d447..f0578468a 100644 --- a/plugins/scheduler-k3s/triggers.go +++ b/plugins/scheduler-k3s/triggers.go @@ -801,15 +801,13 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args [] dokkuRmContainer := os.Getenv("DOKKU_RM_CONTAINER") if dokkuRmContainer == "" { resp, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ - Trigger: "config-get", - Args: []string{appName, "DOKKU_RM_CONTAINER"}, - CaptureOutput: true, + Trigger: "config-get", + Args: []string{appName, "DOKKU_RM_CONTAINER"}, }) if err != nil { resp, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ - Trigger: "config-get-global", - Args: []string{"DOKKU_RM_CONTAINER"}, - CaptureOutput: true, + Trigger: "config-get-global", + Args: []string{"DOKKU_RM_CONTAINER"}, }) if err == nil { dokkuRmContainer = strings.TrimSpace(resp.Stdout) @@ -858,9 +856,8 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args [] } } else if len(args) == 1 { resp, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ - Trigger: "procfile-get-command", - Args: []string{appName, args[0], "5000"}, - CaptureOutput: true, + Trigger: "procfile-get-command", + Args: []string{appName, args[0], "5000"}, }) if err == nil && resp.Stdout != "" { common.LogInfo1Quiet(fmt.Sprintf("Found '%s' in Procfile, running that command", args[0])) diff --git a/plugins/scheduler/src/commands/commands.go b/plugins/scheduler/src/commands/commands.go index 645326b97..baf915d76 100644 --- a/plugins/scheduler/src/commands/commands.go +++ b/plugins/scheduler/src/commands/commands.go @@ -33,9 +33,8 @@ func main() { usage() case "help": result, err := common.CallExecCommand(common.ExecCommandInput{ - Command: "ps", - Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, - CaptureOutput: true, + Command: "ps", + Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())}, }) if err == nil && strings.Contains(result.StdoutContents(), "--all") { fmt.Println(helpContent)