Merge pull request #7178 from edwardmlyte/simplify-version-check
Simplify version check for port count argument
This commit is contained in:
commit
c8a39e939a
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue