From 630b7466d6ce77efa7526b6e688582bee203de14 Mon Sep 17 00:00:00 2001 From: Dave Sanderson Date: Tue, 12 Dec 2017 11:49:10 -0700 Subject: [PATCH] updated test to remove old DefaultTmpDir reference Fixed sudo logic Fixed error message format issue for OSType check --- provisioner/salt-masterless/provisioner.go | 4 ++-- provisioner/salt-masterless/provisioner_test.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index ebdc5eeb9..1e9cffc48 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -130,7 +130,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { var ok bool p.guestOSTypeConfig, ok = guestOSTypeConfigs[p.config.GuestOSType] if !ok { - return fmt.Errorf("Invalid guest_os_type: \"$\"", p.config.GuestOSType) + return fmt.Errorf("Invalid guest_os_type: \"%s\"", p.config.GuestOSType) } p.guestCommands, err = provisioner.NewGuestCommands(p.config.GuestOSType, !p.config.DisableSudo) @@ -356,7 +356,7 @@ func (p *Provisioner) Cancel() { // Prepends sudo to supplied command if config says to func (p *Provisioner) sudo(cmd string) string { - if p.config.DisableSudo || p.config.GuestOSType != provisioner.WindowsOSType { + if p.config.DisableSudo || (p.config.GuestOSType == provisioner.WindowsOSType) { return cmd } diff --git a/provisioner/salt-masterless/provisioner_test.go b/provisioner/salt-masterless/provisioner_test.go index 2b40887d3..a02113198 100644 --- a/provisioner/salt-masterless/provisioner_test.go +++ b/provisioner/salt-masterless/provisioner_test.go @@ -1,11 +1,12 @@ package saltmasterless import ( - "github.com/hashicorp/packer/packer" "io/ioutil" "os" "strings" "testing" + + "github.com/hashicorp/packer/packer" ) func testConfig() map[string]interface{} { @@ -31,7 +32,7 @@ func TestProvisionerPrepare_Defaults(t *testing.T) { t.Fatalf("err: %s", err) } - if p.config.TempConfigDir != DefaultTempConfigDir { + if p.config.TempConfigDir != p.guestOSTypeConfig.tempDir { t.Errorf("unexpected temp config dir: %s", p.config.TempConfigDir) } }