Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/commands/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions cli/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (.*),")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the previous regex used for validation? Seems we've removed all constraints from versioning. Maybe it should still exclude spaces?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format is "Docker version [theversionnumber], build [buildhash]" so feel comfortable (for now) grabbing everything before the space.

return re.FindAllStringSubmatch(string(output), -1)[0][1]
}

func GetCurrentDockerVersion() *version.Version {
versionNumber := GetRawCurrentDockerVersion()
return version.Must(version.NewVersion(versionNumber))
}

Expand Down