diff options
author | Lamont Granquist <lamont@chef.io> | 2020-06-23 09:49:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-23 09:49:43 -0700 |
commit | 38b84c24a3f01eebf4ab043ff34dbabcfde55038 (patch) | |
tree | b3964d2344d67867c0dbc5b914ebd68e0232d62d | |
parent | efd5fc144618a46b73f9cbb91f9ad1a6919cc99f (diff) | |
parent | 4b76066272f3912332a7172673a4eaec231c5fdd (diff) | |
download | chef-38b84c24a3f01eebf4ab043ff34dbabcfde55038.tar.gz |
Merge pull request #10025 from chef/lcg/config-value-aggressive-deprecation
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 15 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 0c4e561b0a..48ff008d22 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -703,8 +703,17 @@ class Chef true end + # FIXME: someone needs to clean this up properly: https://github.com/chef/chef/issues/9645 + # This code is deliberately left without an abstraction around deprecating the config options to avoid knife plugins from + # using those methods (which will need to be deprecated and break them) via inheritance (ruby does not have a true `private` + # so the lack of any inheritable implementation is because of that). + # def winrm_auth_method - config_value(:winrm_auth_method, :winrm_authentication_protocol, "negotiate") + config.key?(:winrm_auth_method) ? config[:winrm_auth_method] : config.key?(:winrm_authentications_protocol) ? config[:winrm_authentication_protocol] : "negotiate" # rubocop:disable Style/NestedTernaryOperator + end + + def ssh_verify_host_key + config.key?(:ssh_verify_host_key) ? config[:ssh_verify_host_key] : config.key?(:host_key_verify) ? config[:host_key_verify] : "always" # rubocop:disable Style/NestedTernaryOperator end # Fail if using plaintext auth without ssl because @@ -905,7 +914,7 @@ class Chef { self_signed: config[:winrm_no_verify_cert] === true } elsif ssh? # Fall back to the old knife config key name for back compat. - { verify_host_key: config_value(:ssh_verify_host_key, :host_key_verify, "always") } + { verify_host_key: ssh_verify_host_key } else {} end @@ -1051,7 +1060,7 @@ class Chef # @api deprecated # def config_value(key, fallback_key = nil, default = nil) - Chef.deprecated(:knife_bootstrap_apis, "Use of config_value without a fallback_key is deprecated. Knife plugin authors should access the config hash directly, which does correct merging of cli and config options.") if fallback_key.nil? + Chef.deprecated(:knife_bootstrap_apis, "Use of config_value is deprecated. Knife plugin authors should access the config hash directly, which does correct merging of cli and config options.") if config.key?(key) # the first key is the primary key so we check the merged hash first config[key] diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index ff61af43c4..f19f28cdb2 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -1927,6 +1927,7 @@ describe Chef::Knife::Bootstrap do Chef::Config[:knife][:test_key_c] = "c from Chef::Config" Chef::Config[:knife][:alt_test_key_c] = "alt c from Chef::Config" knife.merge_configs + Chef::Config[:treat_deprecation_warnings_as_errors] = false end it "returns the Chef::Config value from the cli when the CLI key is set" do |