add timeout for b2d download

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2015-01-30 12:41:35 -05:00
parent d1ee81453c
commit feb34030c2
No known key found for this signature in database
GPG Key ID: A519480096146526
1 changed files with 12 additions and 4 deletions

View File

@ -20,9 +20,7 @@ func defaultTimeout(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, timeout)
}
// Get the latest boot2docker release tag name (e.g. "v0.6.0").
// FIXME: find or create some other way to get the "latest release" of boot2docker since the GitHub API has a pretty low rate limit on API requests
func GetLatestBoot2DockerReleaseURL() (string, error) {
func getClient() *http.Client {
transport := http.Transport{
Dial: defaultTimeout,
}
@ -31,6 +29,14 @@ func GetLatestBoot2DockerReleaseURL() (string, error) {
Transport: &transport,
}
return &client
}
// Get the latest boot2docker release tag name (e.g. "v0.6.0").
// FIXME: find or create some other way to get the "latest release" of boot2docker since the GitHub API has a pretty low rate limit on API requests
func GetLatestBoot2DockerReleaseURL() (string, error) {
client := getClient()
rsp, err := client.Get("https://api.github.com/repos/boot2docker/boot2docker/releases")
if err != nil {
return "", err
@ -54,7 +60,9 @@ func GetLatestBoot2DockerReleaseURL() (string, error) {
// Download boot2docker ISO image for the given tag and save it at dest.
func DownloadISO(dir, file, url string) error {
rsp, err := http.Get(url)
client := getClient()
rsp, err := client.Get(url)
if err != nil {
return err
}