From ea609801b5df4abb940ae3c6f5927f903dc0fdb3 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 14 Mar 2024 01:51:16 -0400 Subject: [PATCH] chore: remove unused plugn code --- plugins/common/subprocess.go | 88 ------------------------------------ 1 file changed, 88 deletions(-) diff --git a/plugins/common/subprocess.go b/plugins/common/subprocess.go index 8a6187fb9..be67da2f1 100644 --- a/plugins/common/subprocess.go +++ b/plugins/common/subprocess.go @@ -4,92 +4,12 @@ import ( "fmt" "io" "os" - "os/exec" "path/filepath" "strings" "github.com/codeskyblue/go-sh" ) -// ShellCmd represents a shell command to be run for dokku -type ShellCmd struct { - Env map[string]string - Command *exec.Cmd - CommandString string - Args []string - ShowOutput bool - ExitError *exec.ExitError -} - -// NewShellCmd returns a new ShellCmd struct -// -// Deprecated: use CallExecCommand instead -func NewShellCmd(command string) *ShellCmd { - items := strings.Split(command, " ") - cmd := items[0] - args := items[1:] - return NewShellCmdWithArgs(cmd, args...) -} - -// NewShellCmdWithArgs returns a new ShellCmd struct -// -// Deprecated: use CallExecCommand instead -func NewShellCmdWithArgs(cmd string, args ...string) *ShellCmd { - commandString := strings.Join(append([]string{cmd}, args...), " ") - - return &ShellCmd{ - Command: exec.Command(cmd, args...), - CommandString: commandString, - Args: args, - ShowOutput: true, - } -} - -func (sc *ShellCmd) setup() { - env := os.Environ() - for k, v := range sc.Env { - env = append(env, fmt.Sprintf("%s=%s", k, v)) - } - sc.Command.Env = env - if sc.ShowOutput { - sc.Command.Stdout = os.Stdout - sc.Command.Stderr = os.Stderr - } -} - -// Execute is a lightweight wrapper around exec.Command -func (sc *ShellCmd) Execute() bool { - sc.setup() - - if err := sc.Command.Run(); err != nil { - exitError, ok := err.(*exec.ExitError) - if ok { - sc.ExitError = exitError - } - return false - } - return true -} - -// Start is a wrapper around exec.Command.Start() -func (sc *ShellCmd) Start() error { - sc.setup() - - return sc.Command.Start() -} - -// Output is a lightweight wrapper around exec.Command.Output() -func (sc *ShellCmd) Output() ([]byte, error) { - sc.setup() - return sc.Command.Output() -} - -// CombinedOutput is a lightweight wrapper around exec.Command.CombinedOutput() -func (sc *ShellCmd) CombinedOutput() ([]byte, error) { - sc.setup() - return sc.Command.CombinedOutput() -} - // PlugnTrigger fire the given plugn trigger with the given args // // Deprecated: use CallPlugnTrigger instead @@ -132,14 +52,6 @@ func PlugnTriggerOutput(triggerName string, args ...string) ([]byte, error) { return readStdout, err } -// PlugnTriggerOutputAsString fires the given plugn trigger with the given args and returns the string contents instead of bytes -// -// Deprecated: use CallPlugnTrigger with CaptureOutput=true instead -func PlugnTriggerOutputAsString(triggerName string, args ...string) (string, error) { - b, err := PlugnTriggerOutput(triggerName, args...) - return strings.TrimSpace(string(b[:])), err -} - // PlugnTriggerSetup sets up a plugn trigger call // // Deprecated: use CallPlugnTrigger instead