Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,16 +564,23 @@ func cmdIP() error {
func cmdDownload() error {
url := B2D.ISOURL

re := regexp.MustCompile("https://api.github.com/repos/([^/]+)/([^/]+)/releases")
if matches := re.FindStringSubmatch(url); len(matches) == 3 {
// match github (enterprise) release urls:
// https://api.github.com/repos/../../relases or
// https://some.github.enterprise/api/v3/repos/../../relases
re := regexp.MustCompile("https://([^/]+)(/api/v3)?/repos/([^/]+)/([^/]+)/releases")
if matches := re.FindStringSubmatch(url); len(matches) == 5 {
tag, err := getLatestReleaseName(url)
if err != nil {
return fmt.Errorf("Failed to get latest release: %s", err)
}
org := matches[1]
repo := matches[2]
fmt.Printf("Latest release for %s/%s is %s\n", org, repo, tag)
url = fmt.Sprintf("https://github.com/%s/%s/releases/download/%s/boot2docker.iso", org, repo, tag)
host := matches[1]
org := matches[3]
repo := matches[4]
if host == "api.github.com" {
host = "github.com"
}
fmt.Printf("Latest release for %s/%s/%s is %s\n", host, org, repo, tag)
url = fmt.Sprintf("https://%s/%s/%s/releases/download/%s/boot2docker.iso", host, org, repo, tag)
}

fmt.Println("Downloading boot2docker ISO image...")
Expand Down