Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit da6f800

Browse files
committed
Merge pull request #339 from databus23/enterprise_isourl
Support github enterprise release urls for ISO
2 parents ccd9032 + bdae52f commit da6f800

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

cmds.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,16 +564,23 @@ func cmdIP() error {
564564
func cmdDownload() error {
565565
url := B2D.ISOURL
566566

567-
re := regexp.MustCompile("https://api.github.com/repos/([^/]+)/([^/]+)/releases")
568-
if matches := re.FindStringSubmatch(url); len(matches) == 3 {
567+
// match github (enterprise) release urls:
568+
// https://api.github.com/repos/../../relases or
569+
// https://some.github.enterprise/api/v3/repos/../../relases
570+
re := regexp.MustCompile("https://([^/]+)(/api/v3)?/repos/([^/]+)/([^/]+)/releases")
571+
if matches := re.FindStringSubmatch(url); len(matches) == 5 {
569572
tag, err := getLatestReleaseName(url)
570573
if err != nil {
571574
return fmt.Errorf("Failed to get latest release: %s", err)
572575
}
573-
org := matches[1]
574-
repo := matches[2]
575-
fmt.Printf("Latest release for %s/%s is %s\n", org, repo, tag)
576-
url = fmt.Sprintf("https://github.com/%s/%s/releases/download/%s/boot2docker.iso", org, repo, tag)
576+
host := matches[1]
577+
org := matches[3]
578+
repo := matches[4]
579+
if host == "api.github.com" {
580+
host = "github.com"
581+
}
582+
fmt.Printf("Latest release for %s/%s/%s is %s\n", host, org, repo, tag)
583+
url = fmt.Sprintf("https://%s/%s/%s/releases/download/%s/boot2docker.iso", host, org, repo, tag)
577584
}
578585

579586
fmt.Println("Downloading boot2docker ISO image...")

0 commit comments

Comments
 (0)