Use go-version for comparison
This commit is contained in:
parent
346f5d9bba
commit
4437f8d8ba
|
@ -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{
|
||||||
|
|
Loading…
Reference in New Issue