refactor: remove all calls to common.NewShellCmd

At this point, the only usage of go-sh should be by plugin trigger calls.
This commit is contained in:
Jose Diaz-Gonzalez
2024-02-13 01:09:24 -05:00
parent 24b32432e6
commit 44dd933638
10 changed files with 207 additions and 234 deletions

View File

@@ -2,8 +2,6 @@ package repo
import (
"fmt"
"os"
"strings"
"github.com/dokku/dokku/plugins/common"
)
@@ -33,18 +31,16 @@ func PurgeCache(appName string) error {
if len(containerIDs) > 0 {
common.DockerRemoveContainers(containerIDs)
}
purgeCacheCmd := common.NewShellCmd(strings.Join([]string{
common.DockerBin(),
"volume",
"rm", "-f", fmt.Sprintf("cache-%s", appName)}, " "))
purgeCacheCmd.ShowOutput = false
purgeCacheCmd.Command.Stderr = os.Stderr
if !purgeCacheCmd.Execute() {
exitCode := 1
if purgeCacheCmd.ExitError != nil {
exitCode = purgeCacheCmd.ExitError.ExitCode()
}
return &PurgeCacheFailed{exitCode}
result, err := common.CallExecCommand(common.ExecCommandInput{
Command: common.DockerBin(),
Args: []string{"volume", "rm", "-f", fmt.Sprintf("cache-%s", appName)},
StreamStderr: true,
})
if err != nil {
return fmt.Errorf("Unable to remove cache volume: %w", err)
}
if result.ExitCode != 0 {
return &PurgeCacheFailed{result.ExitCode}
}
return nil