-
Notifications
You must be signed in to change notification settings - Fork 95
Add configuration flag allowing the use of a custom b2d ISO source URL #267
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import ( | |
"fmt" | ||
"os" | ||
"os/exec" | ||
"regexp" | ||
"runtime" | ||
"strings" | ||
"time" | ||
|
@@ -406,15 +407,21 @@ func cmdIP() error { | |
|
||
// Download the boot2docker ISO image. | ||
func cmdDownload() error { | ||
fmt.Println("Downloading boot2docker ISO image...") | ||
url := "https://api.github.com/repos/boot2docker/boot2docker/releases" | ||
tag, err := getLatestReleaseName(url) | ||
if err != nil { | ||
return fmt.Errorf("Failed to get latest release: %s", err) | ||
url := B2D.ISOURL | ||
|
||
re := regexp.MustCompile("https://api.github.com/repos/([^/]+)/([^/]+)/releases") | ||
if matches := re.FindStringSubmatch(url); len(matches) == 3 { | ||
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) | ||
} | ||
fmt.Printf("Latest release is %s\n", tag) | ||
|
||
url = fmt.Sprintf("https://github.com/boot2docker/boot2docker/releases/download/%s/boot2docker.iso", tag) | ||
fmt.Println("Downloading boot2docker ISO image...") | ||
if err := download(B2D.ISO, url); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo it would be better if the custom iso was not saved as 'boot2docker.iso' - for extra credit, having the b2d.iso's each save to a versioned file would be very awesome, but don't mind me :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we turn around that PR as discussed just above so that the flag is |
||
return fmt.Errorf("Failed to download ISO image: %s", err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
regexp
s thatMustCompile
, it is typical to make avar
outside the function so that the failure will happen immediately at startup... but probably not a big deal in this case.Otherwise, LGTM.