From b7e981c6d15f2cdf589576dc9573261cbfa57f55 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 30 Jun 2015 14:03:06 +0200 Subject: [PATCH 1/2] Fixes issue #2568 When surrounding the version with quotes, even no version (an empty string) will be accepted as parameter. The install.sh script treats an empty version string the same as no when version is set. So it will then just use the latest available version. --- builtin/provisioners/chef/linux_provisioner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/provisioners/chef/linux_provisioner.go b/builtin/provisioners/chef/linux_provisioner.go index 84126fd451a1..e14288437903 100644 --- a/builtin/provisioners/chef/linux_provisioner.go +++ b/builtin/provisioners/chef/linux_provisioner.go @@ -33,7 +33,7 @@ func (p *Provisioner) linuxInstallChefClient( } // Then execute the install.sh scrip to download and install Chef Client - err = p.runCommand(o, comm, fmt.Sprintf("%sbash ./install.sh -v %s", prefix, p.Version)) + err = p.runCommand(o, comm, fmt.Sprintf("%sbash ./install.sh -v %q", prefix, p.Version)) if err != nil { return err } From 3d03f4b2aa02a5b7df416f218a2b536168058b93 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 30 Jun 2015 14:13:36 +0200 Subject: [PATCH 2/2] Fixing the tests --- builtin/provisioners/chef/linux_provisioner_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/provisioners/chef/linux_provisioner_test.go b/builtin/provisioners/chef/linux_provisioner_test.go index 4daa5e534d6f..e41c5b8dafe1 100644 --- a/builtin/provisioners/chef/linux_provisioner_test.go +++ b/builtin/provisioners/chef/linux_provisioner_test.go @@ -24,7 +24,7 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { Commands: map[string]bool{ "sudo curl -LO https://www.chef.io/chef/install.sh": true, - "sudo bash ./install.sh -v ": true, + "sudo bash ./install.sh -v \"\"": true, "sudo rm -f install.sh": true, }, }, @@ -41,7 +41,7 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { Commands: map[string]bool{ "curl -LO https://www.chef.io/chef/install.sh": true, - "bash ./install.sh -v ": true, + "bash ./install.sh -v \"\"": true, "rm -f install.sh": true, }, }, @@ -59,7 +59,7 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { Commands: map[string]bool{ "proxy_http='http://proxy.local' curl -LO https://www.chef.io/chef/install.sh": true, - "proxy_http='http://proxy.local' bash ./install.sh -v ": true, + "proxy_http='http://proxy.local' bash ./install.sh -v \"\"": true, "proxy_http='http://proxy.local' rm -f install.sh": true, }, }, @@ -80,7 +80,7 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { "proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " + "curl -LO https://www.chef.io/chef/install.sh": true, "proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " + - "bash ./install.sh -v ": true, + "bash ./install.sh -v \"\"": true, "proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " + "rm -f install.sh": true, }, @@ -99,7 +99,7 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { Commands: map[string]bool{ "curl -LO https://www.chef.io/chef/install.sh": true, - "bash ./install.sh -v 11.18.6": true, + "bash ./install.sh -v \"11.18.6\"": true, "rm -f install.sh": true, }, },