Support future versions of Parallels by using the latest driver

If the Parallels Desktop for Mac version is higher than the latest
Packer driver use the latest available driver. Before this Packer needed
to be updated with every new version of PD even if there was no change
to the driver.
This commit is contained in:
Rickard von Essen 2016-07-02 22:18:54 +02:00
parent a20d979eba
commit fb00d07d20
1 changed files with 9 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"log"
"os/exec"
"runtime"
"strconv"
"strings"
)
@ -125,6 +126,14 @@ func NewDriver() (Driver, error) {
supportedVersions = append(supportedVersions, v)
}
latestDriver := 11
version, _ := drivers[strconv.Itoa(latestDriver)].Version()
majVer, _ := strconv.Atoi(strings.SplitN(version, ".", 2)[0])
if majVer > latestDriver {
log.Printf("Your version of Parallels Desktop for Mac is %s, Packer will use driver for version %d.", version, latestDriver)
return drivers[strconv.Itoa(latestDriver)], nil
}
return nil, fmt.Errorf(
"Unable to initialize any driver. Supported Parallels Desktop versions: "+
"%s\n", strings.Join(supportedVersions, ", "))