From 21a2de2014f80ce157e757b1450622ade40573c2 Mon Sep 17 00:00:00 2001 From: Fabien Jakimowicz Date: Tue, 10 Nov 2015 19:06:16 +0100 Subject: [PATCH 1/3] remove ~ in path when cooking on a windows host to prevent the creation of a folder named ~ which is not usable by chef --- lib/chef/knife/solo_cook.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/chef/knife/solo_cook.rb b/lib/chef/knife/solo_cook.rb index 57be8051..c90f5f29 100644 --- a/lib/chef/knife/solo_cook.rb +++ b/lib/chef/knife/solo_cook.rb @@ -112,8 +112,11 @@ def validate! end def provisioning_path - # TODO ~ will likely break on cmd.exe based windows sessions - config_value(:provisioning_path, '~/chef-solo') + if windows_node? + config_value(:provisioning_path, 'chef-solo') + else + config_value(:provisioning_path, '~/chef-solo') + end end def sync_kitchen From 8042c8e1bc18c64823fc12740873dfd67aecf1c8 Mon Sep 17 00:00:00 2001 From: Fabien jakimowicz Date: Tue, 1 Mar 2016 16:52:39 +0100 Subject: [PATCH 2/3] stubs windows_node? to allow test to pass again --- test/solo_cook_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/solo_cook_test.rb b/test/solo_cook_test.rb index 067ebdb1..d2bd6b1b 100644 --- a/test/solo_cook_test.rb +++ b/test/solo_cook_test.rb @@ -368,6 +368,7 @@ def command(*args) cmd.stubs(:run_portable_mkdir_p) cmd.stubs(:rsync) cmd.stubs(:stream_command).returns(SuccessfulResult.new) + cmd.stubs(:windows_node? => false) cmd end end From 2a701e790128ee66a02feb6c77dbb657c48b92de Mon Sep 17 00:00:00 2001 From: Fabien jakimowicz Date: Tue, 1 Mar 2016 16:58:17 +0100 Subject: [PATCH 3/3] testing if tilde is removed on windows node --- test/solo_cook_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/solo_cook_test.rb b/test/solo_cook_test.rb index d2bd6b1b..3ccdb163 100644 --- a/test/solo_cook_test.rb +++ b/test/solo_cook_test.rb @@ -347,6 +347,15 @@ def test_passes_override_runlist_to_chef_solo assert_chef_solo_option "--override-runlist=sandbox::default", "-o sandbox::default" end + def test_removes_tilde_on_windows_node + in_kitchen do + cmd = command("somehost") + cmd.unstub(:windows_node?) + cmd.stubs(:windows_node? => true) + assert_equal 'chef-solo', cmd.provisioning_path + end + end + # Asserts that the chef_solo_option is passed to chef-solo iff cook_option # is specified for the cook command def assert_chef_solo_option(cook_option, chef_solo_option)