From fb00d07d20420d9d73bf175f1c2f18edcb1eb1e7 Mon Sep 17 00:00:00 2001 From: Rickard von Essen Date: Sat, 2 Jul 2016 22:18:54 +0200 Subject: [PATCH] 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. --- builder/parallels/common/driver.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/builder/parallels/common/driver.go b/builder/parallels/common/driver.go index 21870f394..fb83e52d1 100644 --- a/builder/parallels/common/driver.go +++ b/builder/parallels/common/driver.go @@ -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, ", "))