Fix hack/test-cmd.sh test.

This commit is contained in:
Wojciech Tyczynski
2015-02-05 01:58:26 +01:00
parent ead67108ce
commit 524cdba101
6 changed files with 36 additions and 29 deletions

View File

@@ -17,11 +17,9 @@ limitations under the License.
package util
import (
"os"
"os/exec"
"strings"
"github.com/fsouza/go-dockerclient"
"github.com/golang/glog"
)
@@ -38,26 +36,3 @@ func GetHostname(hostnameOverride string) string {
}
return strings.TrimSpace(string(hostname))
}
// Get a docker endpoint, either from the string passed in, or $DOCKER_HOST environment variables
func GetDockerEndpoint(dockerEndpoint string) string {
var endpoint string
if len(dockerEndpoint) > 0 {
endpoint = dockerEndpoint
} else if len(os.Getenv("DOCKER_HOST")) > 0 {
endpoint = os.Getenv("DOCKER_HOST")
} else {
endpoint = "unix:///var/run/docker.sock"
}
glog.Infof("Connecting to docker on %s", endpoint)
return endpoint
}
func ConnectToDockerOrDie(dockerEndpoint string) *docker.Client {
client, err := docker.NewClient(GetDockerEndpoint(dockerEndpoint))
if err != nil {
glog.Fatal("Couldn't connect to docker.")
}
return client
}