From 570254c56e048bd3c1322154eb5bde949bb0aa56 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Wed, 8 Mar 2017 11:58:05 -0500 Subject: [PATCH] Handle versions more broadly to account for the new Docker versioning scheme --- cli/commands/machine.go | 2 +- cli/util/util.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/commands/machine.go b/cli/commands/machine.go index 9e27bee..99d04b5 100644 --- a/cli/commands/machine.go +++ b/cli/commands/machine.go @@ -23,7 +23,7 @@ type Machine struct { func (m *Machine) Create(driver string, cpuCount string, memSize string, diskSize string) { m.out.Info.Printf("Creating a %s machine named '%s' with CPU(%s) MEM(%s) DISK(%s)...", driver, m.Name, cpuCount, memSize, diskSize) - boot2dockerUrl := "https://github.com/boot2docker/boot2docker/releases/download/v" + util.GetCurrentDockerVersion().String() + "/boot2docker.iso" + boot2dockerUrl := "https://github.com/boot2docker/boot2docker/releases/download/v" + util.GetRawCurrentDockerVersion() + "/boot2docker.iso" var create *exec.Cmd diff --git a/cli/util/util.go b/cli/util/util.go index 6b5dc59..d465442 100644 --- a/cli/util/util.go +++ b/cli/util/util.go @@ -62,10 +62,14 @@ func AskYesNo(question string) bool { } -func GetCurrentDockerVersion() *version.Version { +func GetRawCurrentDockerVersion() string { output, _ := exec.Command("docker", "--version").Output() - re := regexp.MustCompile("Docker version ([\\d|\\.]+)") - versionNumber := re.FindAllStringSubmatch(string(output), -1)[0][1] + re := regexp.MustCompile("Docker version (.*),") + return re.FindAllStringSubmatch(string(output), -1)[0][1] +} + +func GetCurrentDockerVersion() *version.Version { + versionNumber := GetRawCurrentDockerVersion() return version.Must(version.NewVersion(versionNumber)) }