diff options
author | dheerajd-msys <dheeraj.dubey@msystechnologies.com> | 2019-07-31 12:01:16 +0530 |
---|---|---|
committer | dheerajd-msys <dheeraj.dubey@msystechnologies.com> | 2019-08-06 17:14:42 +0530 |
commit | cd9614237444854de3ed152c776749823ca12f58 (patch) | |
tree | 99ab5026cf31013d85ddce2083fd93ef4d9e9a2b | |
parent | 8bf674755176dbf021019ace42b851d761bda3ce (diff) | |
download | chef-cd9614237444854de3ed152c776749823ca12f58.tar.gz |
fix to avoid conflicts with pattern of other data
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
-rw-r--r-- | lib/chef/knife/core/generic_presenter.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/node_environment_set.rb | 3 | ||||
-rw-r--r-- | spec/unit/knife/node_environment_set_spec.rb | 5 |
3 files changed, 8 insertions, 4 deletions
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index 245496b1d5..90f529a3d9 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -191,11 +191,11 @@ class Chef data = if data.is_a?(Array) data[attr.to_i] + elsif data.respond_to?(:[], false) && data.key?(attr) + data[attr] elsif data.respond_to?(attr.to_sym, false) # handles -a chef_environment and other things that hang of the node and aren't really attributes data.public_send(attr.to_sym) - elsif data.respond_to?(:[], false) && data.key?(attr) - data[attr] else nil end diff --git a/lib/chef/knife/node_environment_set.rb b/lib/chef/knife/node_environment_set.rb index 95aab72625..644b6138b6 100644 --- a/lib/chef/knife/node_environment_set.rb +++ b/lib/chef/knife/node_environment_set.rb @@ -44,8 +44,7 @@ class Chef node.save - config[:attribute] = "chef_environment" - + config[:environment] = @environment output(format_for_display(node)) end diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb index 5b704c4219..6a6d48cc2f 100644 --- a/spec/unit/knife/node_environment_set_spec.rb +++ b/spec/unit/knife/node_environment_set_spec.rb @@ -47,6 +47,11 @@ describe Chef::Knife::NodeEnvironmentSet do @knife.run end + it "sets the environment to config for display" do + @knife.run + expect(@knife.config[:environment]).to eq("bar") + end + it "should print the environment" do expect(@knife).to receive(:output).and_return(true) @knife.run |