Make more robust based on feedback from @ehazlett

Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
Nathan LeClaire 2014-12-16 16:24:48 -08:00
parent fb0407ecdc
commit 154d71ee9c
1 changed files with 28 additions and 18 deletions

View File

@ -127,35 +127,45 @@ func (d *Driver) Create() error {
if d.Boot2DockerURL != "" { if d.Boot2DockerURL != "" {
isoURL = d.Boot2DockerURL isoURL = d.Boot2DockerURL
log.Infof("Downloading boot2docker.iso from %s...", isoURL)
if err := downloadISO(d.storePath, "boot2docker.iso", isoURL); err != nil {
return err
}
} else { } else {
// HACK: Docker 1.3 boot2docker image with client/daemon auth // HACK: Docker 1.3 boot2docker image with client/daemon auth
isoURL = "https://bfirsh.s3.amazonaws.com/boot2docker/boot2docker-1.3.1-identity-auth.iso" isoURL = "https://bfirsh.s3.amazonaws.com/boot2docker/boot2docker-1.3.1-identity-auth.iso"
// todo: check latest release URL, download if it's new
// until then always use "latest"
// isoURL, err = getLatestReleaseURL() // isoURL, err = getLatestReleaseURL()
// if err != nil { // if err != nil {
// return err // return err
// } // }
}
// todo: check latest release URL, download if it's new // todo: use real constant for .docker
// until then always use "latest" rootPath := filepath.Join(drivers.GetHomeDir(), ".docker")
imgPath := filepath.Join(rootPath, "images")
commonIsoPath := filepath.Join(imgPath, "boot2docker.iso")
if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) {
log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath)
// todo: use real constant for .docker // just in case boot2docker.iso has been manually deleted
rootPath := filepath.Join(drivers.GetHomeDir(), ".docker") if _, err := os.Stat(imgPath); os.IsNotExist(err) {
imgPath := filepath.Join(rootPath, "images") if err := os.Mkdir(imgPath, 0700); err != nil {
commonIsoPath := filepath.Join(imgPath, "boot2docker.iso") return err
if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) { }
log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath) }
if err := os.Mkdir(imgPath, 0700); err != nil {
if err := downloadISO(imgPath, "boot2docker.iso", isoURL); err != nil {
return err
}
}
isoDest := filepath.Join(d.storePath, "boot2docker.iso")
if err := cpIso(commonIsoPath, isoDest); err != nil {
return err return err
} }
if err := downloadISO(imgPath, "boot2docker.iso", isoURL); err != nil {
return err
}
}
isoDest := filepath.Join(d.storePath, "boot2docker.iso")
if err := cpIso(commonIsoPath, isoDest); err != nil {
return err
} }
log.Infof("Creating SSH key...") log.Infof("Creating SSH key...")