chore: remove default false values when calling CallExecCommand

This commit is contained in:
Jose Diaz-Gonzalez
2024-02-12 20:07:43 -05:00
parent 8b9dcd2242
commit 047a3c00f5
24 changed files with 20 additions and 55 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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()] {

View File

@@ -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())

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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())

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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,
},

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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]))

View File

@@ -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)