fix: handle error cases in starting a new vector container

This commit is contained in:
Jose Diaz-Gonzalez
2021-01-07 00:12:44 -05:00
parent 441f7ab22a
commit 4bbee232d8
2 changed files with 32 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"strings"
"time"
"github.com/codeskyblue/go-sh"
)
@@ -45,6 +46,18 @@ func ContainerExists(containerID string) bool {
return true
}
// 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 {
time.Sleep(timeout)
if !ContainerIsRunning(containerID) {
return fmt.Errorf("Container %s is not running", containerID)
}
return nil
}
// CopyFromImage copies a file from named image to destination
func CopyFromImage(appName string, image string, source string, destination string) error {
if !VerifyImage(image) {