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