refactor: remove all calls to common.NewShellCmdWithArgs

This commit is contained in:
Jose Diaz-Gonzalez
2024-02-12 20:58:51 -05:00
parent 3c6cc68086
commit d8401a4d86
4 changed files with 76 additions and 56 deletions

View File

@@ -18,6 +18,19 @@ func ContainerIsRunning(containerID string) bool {
return strings.TrimSpace(string(b[:])) == "true"
}
// ContainerStart runs 'docker container start' against an existing container
func ContainerStart(containerID string) bool {
result, err := CallExecCommand(ExecCommandInput{
Command: DockerBin(),
Args: []string{"container", "start", containerID},
StreamStderr: true,
})
if err != nil {
return false
}
return result.ExitCode == 0
}
// ContainerRemove runs 'docker container remove' against an existing container
func ContainerRemove(containerID string) bool {
result, err := CallExecCommand(ExecCommandInput{
@@ -43,6 +56,19 @@ func ContainerExists(containerID string) bool {
return result.ExitCode == 0
}
// ContainerWait runs 'docker container wait' against an existing container
func ContainerWait(containerID string) bool {
result, err := CallExecCommand(ExecCommandInput{
Command: DockerBin(),
Args: []string{"container", "wait", containerID},
StreamStderr: true,
})
if err != nil {
return false
}
return result.ExitCode == 0
}
// ContainerWaitTilReady will wait timeout seconds and then check if a container is running
// returning an error if it is not running at the end of the timeout
func ContainerWaitTilReady(containerID string, timeout time.Duration) error {