chore: remove all direct usage of go-sh outside of plugin trigger setup

The new way is to use CallExecCommand instead.
This commit is contained in:
Jose Diaz-Gonzalez
2024-02-12 19:28:23 -05:00
parent 688ee518af
commit 8a940c6e47
11 changed files with 99 additions and 99 deletions

View File

@@ -4,12 +4,10 @@ import (
"bytes"
"errors"
"fmt"
"os"
"strconv"
"strings"
"text/template"
"github.com/codeskyblue/go-sh"
"github.com/dokku/dokku/plugins/common"
)
@@ -125,25 +123,23 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
}
func dockerTag(imageID string, imageTag string) bool {
cmd := sh.Command(common.DockerBin(), "image", "tag", imageID, imageTag)
cmd.Stdout = nil
cmd.Stderr = nil
if err := cmd.Run(); err != nil {
return false
}
return true
result, err := common.CallExecCommand(common.ExecCommandInput{
Command: common.DockerBin(),
Args: []string{"image", "tag", imageID, imageTag},
CaptureOutput: false,
StreamStdio: true,
})
return err == nil && result.ExitCode == 0
}
func dockerPush(imageTag string) bool {
cmd := sh.Command(common.DockerBin(), "image", "push", imageTag)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return false
}
return true
result, err := common.CallExecCommand(common.ExecCommandInput{
Command: common.DockerBin(),
Args: []string{"image", "push", imageTag},
CaptureOutput: false,
StreamStdio: true,
})
return err == nil && result.ExitCode == 0
}
func imageCleanup(appName string, imageRepo string, imageTag string, tag int) {

View File

@@ -3,7 +3,6 @@ module github.com/dokku/dokku/plugins/registry
go 1.21
require (
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27
github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000
github.com/spf13/pflag v1.0.5
)
@@ -11,6 +10,7 @@ require (
require (
github.com/alexellis/go-execute/v2 v2.2.1 // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect