Merge pull request #7178 from edwardmlyte/simplify-version-check

Simplify version check for port count argument
This commit is contained in:
Adrien Delorme 2019-01-10 16:07:00 +01:00 committed by GitHub
commit c8a39e939a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

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