diff options
-rw-r--r-- | lib/chef/knife/ssh.rb | 11 | ||||
-rw-r--r-- | spec/unit/knife/ssh_spec.rb | 19 |
2 files changed, 12 insertions, 18 deletions
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index 38ff84ebb5..b039830253 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -170,12 +170,13 @@ class Chef # if a command line attribute was not passed, and we have a # cloud public_hostname, use that. see #configure_attribute # for the source of config[:attribute] and - # config[:override_attribute] - if config[:override_attribute] - host = extract_nested_value(item, config[:override_attribute]) + # config[:attribute_from_cli] + if config[:attribute_from_cli] + host = extract_nested_value(item, config[:attribute_from_cli]) elsif item[:cloud] && item[:cloud][:public_hostname] host = item[:cloud][:public_hostname] else + # ssh attribute from a configuration file or the default will land here host = extract_nested_value(item, config[:attribute]) end # next if we couldn't find the specified attribute in the @@ -413,8 +414,8 @@ class Chef # Thus we can differentiate between a config file value and a command line override at this point by checking config[:attribute] # We can tell here if fqdn was passed from the command line, rather than being the default, by checking config[:attribute] # However, after here, we cannot tell these things, so we must preserve config[:attribute] - config[:override_attribute] = config[:attribute] || Chef::Config[:knife][:ssh_attribute] - config[:attribute] = (config[:override_attribute] || "fqdn").strip + config[:attribute_from_cli] = config[:attribute] + config[:attribute] = (config[:attribute_from_cli] || Chef::Config[:knife][:ssh_attribute] || "fqdn").strip end def cssh diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 3404ce597c..10d63c9c74 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -52,7 +52,7 @@ describe Chef::Knife::Ssh do def self.should_return_specified_attributes it "returns an array of the attributes specified on the command line OR config file, if only one is set" do @knife.config[:attribute] = "ipaddress" - @knife.config[:override_attribute] = "ipaddress" + @knife.config[:attribute_from_cli] = "ipaddress" configure_query([@node_foo, @node_bar]) @knife.should_receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]]) @knife.configure_session @@ -60,7 +60,7 @@ describe Chef::Knife::Ssh do it "returns an array of the attributes specified on the command line even when a config value is set" do @knife.config[:attribute] = "config_file" # this value will be the config file - @knife.config[:override_attribute] = "ipaddress" # this is the value of the command line via #configure_attribute + @knife.config[:attribute_from_cli] = "ipaddress" # this is the value of the command line via #configure_attribute configure_query([@node_foo, @node_bar]) @knife.should_receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]]) @knife.configure_session @@ -155,26 +155,19 @@ describe Chef::Knife::Ssh do @knife.config[:attribute].should == "command_line" end - it "should set override_attribute to the value of attribute from the command line" do + it "should set attribute_from_cli to the value of attribute from the command line" do @knife.config[:attribute] = "command_line" @knife.configure_attribute @knife.config[:attribute].should == "command_line" - @knife.config[:override_attribute].should == "command_line" + @knife.config[:attribute_from_cli].should == "command_line" end - it "should set override_attribute to the value of attribute from the config file" do - Chef::Config[:knife][:ssh_attribute] = "config_file" - @knife.configure_attribute - @knife.config[:attribute].should == "config_file" - @knife.config[:override_attribute].should == "config_file" - end - - it "should prefer the command line over the config file for the value of override_attribute" do + it "should prefer the command line over the config file for the value of attribute_from_cli" do Chef::Config[:knife][:ssh_attribute] = "config_file" @knife.config[:attribute] = "command_line" @knife.configure_attribute @knife.config[:attribute].should == "command_line" - @knife.config[:override_attribute].should == "command_line" + @knife.config[:attribute_from_cli].should == "command_line" end end |