diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-11-25 11:13:54 -0800 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-11-25 11:13:54 -0800 |
commit | d3c4c4f9b15ea5abd80e5c90160854e3bae6d5c3 (patch) | |
tree | c94dbacbb9d8e69d426941e3a5d539932b7d63be | |
parent | 90ac5191358550e5521b2ecb8df027cde6a5e44a (diff) | |
parent | 47dbeac97bcb57c0eb90a18992faa44272936db5 (diff) | |
download | chef-d3c4c4f9b15ea5abd80e5c90160854e3bae6d5c3.tar.gz |
Merge branch 'patch-3' of github.com:justanshulsharma/chef
-rw-r--r-- | lib/chef/knife/node_run_list_remove.rb | 14 | ||||
-rw-r--r-- | spec/unit/knife/node_run_list_remove_spec.rb | 21 |
2 files changed, 29 insertions, 6 deletions
diff --git a/lib/chef/knife/node_run_list_remove.rb b/lib/chef/knife/node_run_list_remove.rb index 8519fd590a..4b8953a264 100644 --- a/lib/chef/knife/node_run_list_remove.rb +++ b/lib/chef/knife/node_run_list_remove.rb @@ -27,11 +27,20 @@ class Chef require 'chef/json_compat' end - banner "knife node run_list remove [NODE] [ENTRIES] (options)" + banner "knife node run_list remove [NODE] [ENTRY[,ENTRY]] (options)" def run node = Chef::Node.load(@name_args[0]) - entries = @name_args[1].split(',') + + if @name_args.size > 2 + # Check for nested lists and create a single plain one + entries = @name_args[1..-1].map do |entry| + entry.split(',').map { |e| e.strip } + end.flatten + else + # Convert to array and remove the extra spaces + entries = @name_args[1].split(',').map { |e| e.strip } + end entries.each { |e| node.run_list.remove(e) } @@ -45,4 +54,3 @@ class Chef end end end - diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb index ea951e21dd..2c3d29ae73 100644 --- a/spec/unit/knife/node_run_list_remove_spec.rb +++ b/spec/unit/knife/node_run_list_remove_spec.rb @@ -66,9 +66,24 @@ describe Chef::Knife::NodeRunListRemove do expect(@node.run_list).not_to include('role[monkey]') expect(@node.run_list).not_to include('recipe[duck::type]') end + + it "should remove the items from the run list when name args contains whitespace" do + @node.run_list << 'role[monkey]' + @node.run_list << 'recipe[duck::type]' + @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]' ] + @knife.run + @node.run_list.should_not include('role[monkey]') + @node.run_list.should_not include('recipe[duck::type]') + end + + it "should remove the items from the run list when name args contains multiple run lists" do + @node.run_list << 'role[blah]' + @node.run_list << 'recipe[duck::type]' + @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]', 'role[blah]' ] + @knife.run + @node.run_list.should_not include('role[monkey]') + @node.run_list.should_not include('recipe[duck::type]') + end end end end - - - |