mirror of https://github.com/docker/docs.git
add timeout for b2d download
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
d1ee81453c
commit
feb34030c2
16
utils/b2d.go
16
utils/b2d.go
|
@ -20,9 +20,7 @@ func defaultTimeout(network, addr string) (net.Conn, error) {
|
||||||
return net.DialTimeout(network, addr, timeout)
|
return net.DialTimeout(network, addr, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the latest boot2docker release tag name (e.g. "v0.6.0").
|
func getClient() *http.Client {
|
||||||
// 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) {
|
|
||||||
transport := http.Transport{
|
transport := http.Transport{
|
||||||
Dial: defaultTimeout,
|
Dial: defaultTimeout,
|
||||||
}
|
}
|
||||||
|
@ -31,6 +29,14 @@ func GetLatestBoot2DockerReleaseURL() (string, error) {
|
||||||
Transport: &transport,
|
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")
|
rsp, err := client.Get("https://api.github.com/repos/boot2docker/boot2docker/releases")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -54,7 +60,9 @@ func GetLatestBoot2DockerReleaseURL() (string, error) {
|
||||||
|
|
||||||
// Download boot2docker ISO image for the given tag and save it at dest.
|
// Download boot2docker ISO image for the given tag and save it at dest.
|
||||||
func DownloadISO(dir, file, url string) error {
|
func DownloadISO(dir, file, url string) error {
|
||||||
rsp, err := http.Get(url)
|
client := getClient()
|
||||||
|
|
||||||
|
rsp, err := client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue