Use go-version for comparison

This commit is contained in:
Ed Maxwell-Lyte 2019-01-09 16:22:33 +00:00
parent 346f5d9bba
commit 4437f8d8ba
1 changed files with 12 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package common
import (
"bytes"
"fmt"
"github.com/hashicorp/go-version"
"log"
"os/exec"
"regexp"
@ -26,10 +27,17 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string, portcoun
portCountArg := "--portcount"
for _, prefix := range [7]string{"0.", "1.", "2.", "3.", "4.0", "4.1", "4.2"} {
if strings.HasPrefix(version, prefix) {
portCountArg = "--sataportcount"
}
currentVersion, err := version.NewVersion(version)
if err != nil {
return err
}
versionUsingPortCount, err := version.NewVersion("4.3")
if err != nil {
return err
}
if currentVersion.LessThan(versionUsingPortCount) {
portCountArg = "--sataportcount"
}
command := []string{