From e40c90423f5ea05edbed7806f2c3bc49820f8e92 Mon Sep 17 00:00:00 2001 From: Ed Maxwell-Lyte <2248005+edwardmlyte@users.noreply.github.com> Date: Tue, 8 Jan 2019 14:14:21 +0000 Subject: [PATCH 1/5] Reverse default port count virtualbox argument As we know the exact versions that used the old `sataportcount` option, it's safe to assume we want to use the newer `portcount` option for everything else. Reversed the option check and use the `portcount` option by default. Prevents needing to update this for future major versions of VirtualBox. --- builder/virtualbox/common/driver_4_2.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index b5dc64c67..54ec4ddde 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -24,9 +24,9 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string, portcoun return err } - portCountArg := "--sataportcount" - if strings.HasPrefix(version, "4.3") || strings.HasPrefix(version, "5.") || strings.HasPrefix(version, "6.") { - portCountArg = "--portcount" + portCountArg = "--portcount" + if strings.HasPrefix(version, "1.") || strings.HasPrefix(version, "2.") || strings.HasPrefix(version, "3.") || strings.HasPrefix(version, "4.0") || strings.HasPrefix(version, "4.1") || strings.HasPrefix(version, "4.2") { + portCountArg := "--sataportcount" } command := []string{ From e5b1e0f4d93ee2f5ddb9f769369229c493c970ae Mon Sep 17 00:00:00 2001 From: Ed Maxwell-Lyte <2248005+edwardmlyte@users.noreply.github.com> Date: Tue, 8 Jan 2019 15:35:45 +0000 Subject: [PATCH 2/5] Add version 0.x to the rule --- builder/virtualbox/common/driver_4_2.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index 54ec4ddde..c3c11554d 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -25,7 +25,9 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string, portcoun } portCountArg = "--portcount" - if strings.HasPrefix(version, "1.") || strings.HasPrefix(version, "2.") || strings.HasPrefix(version, "3.") || strings.HasPrefix(version, "4.0") || strings.HasPrefix(version, "4.1") || strings.HasPrefix(version, "4.2") { + 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") || + strings.HasPrefix(version, "4.2") { portCountArg := "--sataportcount" } From a9eed311a653eaac735b9e9d74bf300320af6689 Mon Sep 17 00:00:00 2001 From: Ed Maxwell-Lyte <2248005+edwardmlyte@users.noreply.github.com> Date: Tue, 8 Jan 2019 15:58:05 +0000 Subject: [PATCH 3/5] Run gofmt on driver_4_2.go --- builder/virtualbox/common/driver_4_2.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index c3c11554d..8af782947 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -25,9 +25,9 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string, portcoun } 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") || - strings.HasPrefix(version, "4.2") { + 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") || + strings.HasPrefix(version, "4.2") { portCountArg := "--sataportcount" } From f91b6686179beac7fbf9ff695c1f4bf77d824675 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 8 Jan 2019 16:15:24 +0000 Subject: [PATCH 4/5] Create portCountArg in the if statement You can't assign to something that doesn't exist Co-Authored-By: edwardmlyte --- builder/virtualbox/common/driver_4_2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index 8af782947..9bfa3baf1 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -24,7 +24,7 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string, portcoun return err } - 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") || strings.HasPrefix(version, "4.2") { From 4fc02ea4061fc9398d58da91df7cac9fa5315af7 Mon Sep 17 00:00:00 2001 From: Ed Maxwell-Lyte <2248005+edwardmlyte@users.noreply.github.com> Date: Tue, 8 Jan 2019 16:19:11 +0000 Subject: [PATCH 5/5] Assign to existing var --- builder/virtualbox/common/driver_4_2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index 9bfa3baf1..1a2c8541d 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -28,7 +28,7 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string, portcoun 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") || strings.HasPrefix(version, "4.2") { - portCountArg := "--sataportcount" + portCountArg = "--sataportcount" } command := []string{