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

Commit

Permalink
Make the source URL for the b2d ISO customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
github-brice-jaglin committed Oct 8, 2014
1 parent d35fa59 commit 6cc72c4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ SSHKey = "/Users/sven/.ssh/id_boot2docker"
# name of boot2docker virtual machine
VM = "boot2docker-vm"

# URL pointing either to a Github "/releases" API endpoint to automatically
# retrieve the `boot2docker.iso` asset from the latest released version of a
# repo, or directly to an ISO image
ISOURL = "https://api.github.com/repos/boot2docker/boot2docker/releases"
#ISOURL = "https://github.com/boot2docker/boot2docker/releases/download/v1.0.0/boot2docker.iso"
#ISOURL = "https://internal.corp.org/b2d.iso"

# path to boot2docker ISO image
ISO = "/Users/sven/.boot2docker/boot2docker.iso"

Expand Down
21 changes: 14 additions & 7 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"regexp"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -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 {
return fmt.Errorf("Failed to download ISO image: %s", err)
}
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func config() (*flag.FlagSet, error) {
// removed for now, requires re-parsing a new config file which is too messy
//flags.StringVarP(&B2D.Dir, "dir", "d", dir, "boot2docker config directory.")
B2D.Dir = dir
flags.StringVar(&B2D.ISOURL, "iso-url", "https://api.github.com/repos/boot2docker/boot2docker/releases", "source URL to provision the boot2docker ISO image.")
flags.StringVar(&B2D.ISO, "iso", filepath.Join(dir, "boot2docker.iso"), "path to boot2docker ISO image.")

// Sven disabled this, as it is broken - if I user with a fresh computer downloads
Expand Down
1 change: 1 addition & 0 deletions driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type MachineConfig struct {
SSHKey string // SSH key to send to the vm
VM string // virtual machine name
Dir string // boot2docker directory
ISOURL string // Source URL to retrieve the ISO from
ISO string // boot2docker ISO image path
DiskSize uint // VM disk image size (MB)
Memory uint // VM memory size (MB)
Expand Down

0 comments on commit 6cc72c4

Please sign in to comment.