From 866271327b8dada8f86137e88da8a09f49515866 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Thu, 5 Feb 2015 21:03:07 +0100 Subject: [PATCH 1/2] Support github enterprise release urls for ISO --- cmds.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cmds.go b/cmds.go index 44c8e33..fad228c 100644 --- a/cmds.go +++ b/cmds.go @@ -564,16 +564,24 @@ 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] + host := matches[1] + org := matches[3] + repo := matches[4] 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) + if host == "api.github.com" { + url = fmt.Sprintf("https://github.com/%s/%s/releases/download/%s/boot2docker.iso", org, repo, tag) + } else { + url = fmt.Sprintf("https://%s/%s/%s/releases/download/%s/boot2docker.iso", host, org, repo, tag) + } } fmt.Println("Downloading boot2docker ISO image...") From bdae52fada74fa4277ab4f8a880af973c021e747 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Fri, 6 Feb 2015 09:26:14 +0100 Subject: [PATCH 2/2] Simplify download url generation --- cmds.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmds.go b/cmds.go index fad228c..1c6409c 100644 --- a/cmds.go +++ b/cmds.go @@ -576,12 +576,11 @@ func cmdDownload() error { host := matches[1] org := matches[3] repo := matches[4] - fmt.Printf("Latest release for %s/%s is %s\n", org, repo, tag) if host == "api.github.com" { - url = fmt.Sprintf("https://github.com/%s/%s/releases/download/%s/boot2docker.iso", org, repo, tag) - } else { - url = fmt.Sprintf("https://%s/%s/%s/releases/download/%s/boot2docker.iso", host, org, repo, tag) + 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...")