reg/vendor/github.com/docker/docker-ce/components/engine/integration/internal/requirement/requirement.go
Jess Frazelle ab6c553e6b
update deps
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
2018-03-06 10:41:43 -05:00

26 lines
674 B
Go

package requirement // import "github.com/docker/docker/integration/internal/requirement"
import (
"net/http"
"strings"
"testing"
"time"
)
// HasHubConnectivity checks to see if https://hub.docker.com is
// accessible from the present environment
func HasHubConnectivity(t *testing.T) bool {
// Set a timeout on the GET at 15s
var timeout = 15 * time.Second
var url = "https://hub.docker.com"
client := http.Client{Timeout: timeout}
resp, err := client.Get(url)
if err != nil && strings.Contains(err.Error(), "use of closed network connection") {
t.Fatalf("Timeout for GET request on %s", url)
}
if resp != nil {
resp.Body.Close()
}
return err == nil
}