diff --git a/cmds.go b/cmds.go index 44c8e33..1c6409c 100644 --- a/cmds.go +++ b/cmds.go @@ -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...")