chef 15.10.12-universal-mingw32 → 15.11.3-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -3
  3. data/Rakefile +1 -1
  4. data/lib/chef/application/apply.rb +1 -1
  5. data/lib/chef/application/exit_code.rb +2 -2
  6. data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
  7. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
  8. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
  9. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
  10. data/lib/chef/cookbook_version.rb +4 -4
  11. data/lib/chef/deprecated.rb +1 -1
  12. data/lib/chef/dsl/platform_introspection.rb +1 -1
  13. data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
  14. data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
  15. data/lib/chef/knife.rb +26 -20
  16. data/lib/chef/knife/bootstrap.rb +22 -21
  17. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +12 -8
  18. data/lib/chef/knife/bootstrap/client_builder.rb +23 -19
  19. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
  20. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  21. data/lib/chef/knife/cookbook_site_show.rb +1 -1
  22. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  23. data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
  24. data/lib/chef/knife/ssh.rb +1 -1
  25. data/lib/chef/mixin/create_path.rb +8 -8
  26. data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
  27. data/lib/chef/provider/package/chocolatey.rb +3 -2
  28. data/lib/chef/provider/service/simple.rb +3 -3
  29. data/lib/chef/provider/windows_task.rb +1 -1
  30. data/lib/chef/resource/build_essential.rb +1 -1
  31. data/lib/chef/resource/launchd.rb +4 -4
  32. data/lib/chef/resource/macos_userdefaults.rb +3 -3
  33. data/lib/chef/resource/windows_firewall_rule.rb +8 -4
  34. data/lib/chef/resource/windows_share.rb +4 -4
  35. data/lib/chef/resource/windows_task.rb +13 -13
  36. data/lib/chef/resource_inspector.rb +4 -3
  37. data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
  38. data/lib/chef/version.rb +1 -1
  39. data/lib/chef/win32/api/command_line_helper.rb +89 -0
  40. data/lib/chef/win32/api/file.rb +18 -18
  41. data/lib/chef/win32/file.rb +1 -1
  42. data/lib/chef/win32/process.rb +2 -2
  43. data/spec/functional/resource/chocolatey_package_spec.rb +29 -0
  44. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  45. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  46. data/spec/spec_helper.rb +0 -11
  47. data/spec/support/shared/functional/file_resource.rb +1 -1
  48. data/spec/unit/knife/bootstrap_spec.rb +10 -13
  49. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +6 -0
  50. data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
  51. data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
  52. data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
  53. data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
  54. data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
  55. data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
  56. data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
  57. data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
  58. data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
  59. data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
  60. data/spec/unit/provider/git_spec.rb +3 -3
  61. data/spec/unit/provider/osx_profile_spec.rb +2 -2
  62. data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
  63. data/spec/unit/provider/package/msu_spec.rb +3 -3
  64. data/spec/unit/provider/service/gentoo_service_spec.rb +1 -1
  65. data/spec/unit/provider_resolver_spec.rb +9 -9
  66. data/spec/unit/run_context_spec.rb +1 -1
  67. metadata +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 867bf76bc4dd88b3b9e08fae4c546e691bf74f01ee5589e4a90d661d0e9618f3
4
- data.tar.gz: ba1b42a49bf1f44de4b62227df689012bd82803241fa652bc04eb950eaaa8505
3
+ metadata.gz: 32721068c57f85e60f139ce990019e7b67ef0ac2f07c5affa62646d7af48a3c8
4
+ data.tar.gz: 8a13f1eba9bee7cbaeee4011503fdfd15edee8c2f7e51a9f482cf5f241e886f1
5
5
  SHA512:
6
- metadata.gz: d01279a13ad62bb569c701d5eda29f808c9c0cf73cc957564572bcf41ab8c4529e5b5d06fe1a0f02e6231b779f788d8025e0eade681ed1edf630a59f0f0e0cbd
7
- data.tar.gz: 67eef9fc6bb6ecb0295caec9fc65c88e280ce8fb76cae4ec45edc60415f5f08bec146fdff53c04e352c395714704002b19751366ed66579210bb208bc0865c48
6
+ metadata.gz: 6204fdc0edf0494abbf9d85adeee887e94f95c000eefabd28e09edcca52c676279b86d1f7eed9c8b1874ff089210848354543378de2396639791a062e985d626
7
+ data.tar.gz: 020463f4c2ea7a362b9f4fd4152c9d093318fd99ed0aa304873bc9ab5c7cde7b4c58a3331a59eb42fbc6a89142cd73a6e94ec8b464862c6c350353f55e212498
data/Gemfile CHANGED
@@ -7,7 +7,6 @@ source "https://rubygems.org"
7
7
  # of bundler versions prior to 1.12.0 (https://github.com/bundler/bundler/commit/193a14fe5e0d56294c7b370a0e59f93b2c216eed)
8
8
  gem "chef", path: "."
9
9
 
10
- # necessary until we release ohai 15
11
10
  gem "ohai", git: "https://github.com/chef/ohai.git", branch: "15-stable"
12
11
 
13
12
  gem "chef-utils", path: File.expand_path("../chef-utils", __FILE__) if File.exist?(File.expand_path("../chef-utils", __FILE__))
@@ -23,6 +22,9 @@ end
23
22
 
24
23
  gem "cheffish", "~> 14"
25
24
 
25
+ # avoid bringing in the new http 4 gem that comes with other ffi baggage which breaks builds
26
+ gem "chef-telemetry", "=1.0.3"
27
+
26
28
  group(:omnibus_package) do
27
29
  gem "appbundler"
28
30
  gem "rb-readline"
@@ -30,7 +32,7 @@ group(:omnibus_package) do
30
32
  gem "inspec-core-bin", "~> 4.18" # need to provide the binaries for inspec
31
33
  gem "chef-vault"
32
34
  gem "ed25519" # ed25519 ssh key support done here as it's a native gem we can't put in train
33
- gem "bcrypt_pbkdf" # ed25519 ssh key support done here as it's a native gem we can't put in train
35
+ gem "bcrypt_pbkdf", ">= 1.1.0.rc1" # ed25519 ssh key support done here as it's a native gem we can't put in train
34
36
  end
35
37
 
36
38
  group(:omnibus_package, :pry) do
@@ -65,7 +67,6 @@ group(:development, :test) do
65
67
  gem "rspec-mocks", "~> 3.5"
66
68
  gem "rspec-expectations", "~> 3.5"
67
69
  gem "rspec_junit_formatter", "~> 0.2.0"
68
- gem "simplecov"
69
70
  gem "webmock"
70
71
  gem "fauxhai-ng" # for chef-utils gem
71
72
  end
@@ -84,6 +85,7 @@ eval_gemfile("./Gemfile.local") if File.exist?("./Gemfile.local")
84
85
  # These lines added for Windows development only.
85
86
  # For FFI to call into PowerShell we need the binaries and assemblies located
86
87
  # in the Ruby bindir.
88
+ # The Powershell DLL source lives here: https://github.com/chef/chef-powershell-shim
87
89
  #
88
90
  # We copy (and overwrite) these files every time "bundle <exec|install>" is
89
91
  # executed, just in case they have changed.
data/Rakefile CHANGED
@@ -37,7 +37,7 @@ task :super_install do
37
37
  sh("rake install")
38
38
  end
39
39
 
40
- # Templating the powershell extensions so we can inject distro constants
40
+ # Templating the powershell extensions so we can inject distro constants
41
41
  template_file = ::File.join(::File.dirname(__FILE__), "distro", "templates", "powershell", "chef", "chef.psm1.erb")
42
42
  psm1_path = ::File.join(::File.dirname(__FILE__), "distro", "powershell", "chef")
43
43
  FileUtils.mkdir_p psm1_path
@@ -215,7 +215,7 @@ class Chef::Application::Apply < Chef::Application
215
215
  Chef::Application.fatal!("#{e.class}: #{e.message}", e)
216
216
  end
217
217
 
218
- # Get this party started
218
+ # Get this party started
219
219
  def run(enforce_license = false)
220
220
  reconfigure
221
221
  check_license_acceptance if enforce_license
@@ -139,8 +139,8 @@ class Chef
139
139
  def notify_on_deprecation(message)
140
140
  Chef.deprecated(:exit_code, message)
141
141
  rescue Chef::Exceptions::DeprecatedFeatureError
142
- # Have to rescue this, otherwise this unhandled error preempts
143
- # the current exit code assignment.
142
+ # Have to rescue this, otherwise this unhandled error preempts
143
+ # the current exit code assignment.
144
144
  end
145
145
 
146
146
  def non_standard_exit_code_warning(exit_code)
@@ -204,7 +204,7 @@ class Chef
204
204
  @memory_store.create(path, name, data, *options)
205
205
 
206
206
  elsif path[0] == "cookbooks" && path.length == 2
207
- # Do nothing. The entry gets created when the cookbook is created.
207
+ # Do nothing. The entry gets created when the cookbook is created.
208
208
 
209
209
  # /policy_groups/GROUP/policies/NAME
210
210
  elsif path[0] == "policy_groups" && path[2] == "policies"
@@ -724,8 +724,8 @@ class Chef
724
724
  path[-1] = "#{path[-1]}.json"
725
725
  end
726
726
 
727
- # /acls/containers|nodes|... do NOT drop into the next elsif, and do
728
- # not get .json appended
727
+ # /acls/containers|nodes|... do NOT drop into the next elsif, and do
728
+ # not get .json appended
729
729
 
730
730
  # /nodes|clients|.../x.json
731
731
  elsif path.length == 2
@@ -66,7 +66,7 @@ class Chef
66
66
  # }
67
67
  # }
68
68
  def children
69
- # Grab the names of the children, append json, and make child entries
69
+ # Grab the names of the children, append json, and make child entries
70
70
  @children ||= begin
71
71
  result = []
72
72
  data = root.get_json(api_path)
@@ -71,7 +71,7 @@ class Chef
71
71
  # Children are foo.json and bar.json in this case.
72
72
  #
73
73
  def children
74
- # Grab the names of the children, append json, and make child entries
74
+ # Grab the names of the children, append json, and make child entries
75
75
  @children ||= root.get_json(api_path).keys.sort.map do |key|
76
76
  make_child_entry(key, true)
77
77
  end
@@ -19,7 +19,7 @@ class Chef
19
19
  def children
20
20
  result = []
21
21
  seen = {}
22
- # If multiple things have the same name, the first one wins.
22
+ # If multiple things have the same name, the first one wins.
23
23
  multiplexed_dirs.each do |dir|
24
24
  dir.children.each do |child|
25
25
  if seen[child.name]
@@ -327,10 +327,10 @@ class Chef
327
327
 
328
328
  # extract the preference part from the path.
329
329
  if manifest_record_path =~ %r{(#{Regexp.escape(segment.to_s)}/[^/]+/#{Regexp.escape(dirname)})/.+$}
330
- # Note the specificy_dirname includes the segment and
331
- # dirname argument as above, which is what
332
- # preferences_for_path returns. It could be
333
- # "files/ubuntu-9.10/dirname", for example.
330
+ # Note the specificy_dirname includes the segment and
331
+ # dirname argument as above, which is what
332
+ # preferences_for_path returns. It could be
333
+ # "files/ubuntu-9.10/dirname", for example.
334
334
  specificity_dirname = $1
335
335
 
336
336
  # Record the specificity_dirname only if it's in the list of
@@ -72,7 +72,7 @@ class Chef
72
72
  # Just in case someone uses a symbol in the config by mistake.
73
73
  silence_spec = silence_spec.to_s
74
74
  end
75
- # Check for a silence by deprecation name, or by location.
75
+ # Check for a silence by deprecation name, or by location.
76
76
  self.class.deprecation_key == silence_spec || self.class.deprecation_id.to_s == silence_spec || "chef-#{self.class.deprecation_id}" == silence_spec.downcase || location.include?(silence_spec)
77
77
  end
78
78
  # check if this warning has been silenced by inline comment.
@@ -168,7 +168,7 @@ class Chef
168
168
  has_platform
169
169
  end
170
170
 
171
- # Implementation class for determining platform family dependent values
171
+ # Implementation class for determining platform family dependent values
172
172
  class PlatformFamilyDependentValue
173
173
 
174
174
  # Create a platform family dependent value object.
@@ -46,7 +46,7 @@ class Chef
46
46
  when Chef::Exceptions::PrivateKeyMissing
47
47
  error_description.section("Private Key Not Found:", <<~E)
48
48
  Your private key could not be loaded. If the key file exists, ensure that it is
49
- readable by #{Chef::Dist::CLIENT}.
49
+ readable by #{Chef::Dist::PRODUCT}.
50
50
  E
51
51
  error_description.section("Relevant Config Settings:", <<~E)
52
52
  client_key "#{api_key}"
@@ -99,7 +99,7 @@ class Chef
99
99
  # redirect.
100
100
  def describe_404_error(error_description)
101
101
  error_description.section("Resource Not Found:", <<~E)
102
- The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
102
+ The #{Chef::Dist::SERVER_PRODUCT} returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
103
103
  E
104
104
  error_description.section("Relevant Config Settings:", <<~E)
105
105
  chef_server_url "#{server_url}"
@@ -28,7 +28,7 @@ class Chef
28
28
  humanize_http_exception(error_description)
29
29
  when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
30
30
  error_description.section("Network Error:", <<~E)
31
- There was a network error connecting to the Chef Server:
31
+ There was a network error connecting to the #{Chef::Dist::SERVER_PRODUCT}:
32
32
  #{exception.message}
33
33
  E
34
34
  error_description.section("Relevant Config Settings:", <<~E)
@@ -39,14 +39,14 @@ class Chef
39
39
  when Chef::Exceptions::PrivateKeyMissing
40
40
  error_description.section("Private Key Not Found:", <<~E)
41
41
  Your private key could not be loaded. If the key file exists, ensure that it is
42
- readable by #{Chef::Dist::CLIENT}.
42
+ readable by #{Chef::Dist::PRODUCT}.
43
43
  E
44
44
  error_description.section("Relevant Config Settings:", <<~E)
45
45
  validation_key "#{api_key}"
46
46
  E
47
47
  when Chef::Exceptions::InvalidRedirect
48
48
  error_description.section("Invalid Redirect:", <<~E)
49
- Change your server location in client.rb to the server's FQDN to avoid unwanted redirections.
49
+ Change your #{Chef::Dist::SERVER_PRODUCT} location in client.rb to the #{Chef::Dist::SERVER_PRODUCT}'s FQDN to avoid unwanted redirections.
50
50
  E
51
51
  when EOFError
52
52
  describe_eof_error(error_description)
@@ -61,13 +61,13 @@ class Chef
61
61
  when Net::HTTPUnauthorized
62
62
  if clock_skew?
63
63
  error_description.section("Authentication Error:", <<~E)
64
- Failed to authenticate to the chef server (http 401).
64
+ Failed to authenticate to the #{Chef::Dist::SERVER_PRODUCT} (http 401).
65
65
  The request failed because your clock has drifted by more than 15 minutes.
66
66
  Syncing your clock to an NTP Time source should resolve the issue.
67
67
  E
68
68
  else
69
69
  error_description.section("Authentication Error:", <<~E)
70
- Failed to authenticate to the chef server (http 401).
70
+ Failed to authenticate to the #{Chef::Dist::SERVER_PRODUCT} (http 401).
71
71
  E
72
72
 
73
73
  error_description.section("Server Response:", format_rest_error)
@@ -81,7 +81,7 @@ class Chef
81
81
  end
82
82
  when Net::HTTPForbidden
83
83
  error_description.section("Authorization Error:", <<~E)
84
- Your validation client is not authorized to create the client for this node (HTTP 403).
84
+ Your validation client is not authorized to create the client for this node on the #{Chef::Dist::SERVER_PRODUCT} (HTTP 403).
85
85
  E
86
86
  error_description.section("Possible Causes:", <<~E)
87
87
  * There may already be a client named "#{config[:node_name]}"
@@ -94,7 +94,7 @@ class Chef
94
94
  error_description.section("Server Response:", format_rest_error)
95
95
  when Net::HTTPNotFound
96
96
  error_description.section("Resource Not Found:", <<~E)
97
- The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
97
+ The #{Chef::Dist::SERVER_PRODUCT} returned a HTTP 404. This usually indicates that your chef_server_url configuration is incorrect.
98
98
  E
99
99
  error_description.section("Relevant Config Settings:", <<~E)
100
100
  chef_server_url "#{server_url}"
@@ -345,31 +345,35 @@ class Chef
345
345
  exit(1)
346
346
  end
347
347
 
348
- # keys from mixlib-cli options
349
- def cli_keys
350
- self.class.options.keys
348
+ # This is all set and default mixlib-config values. We only need the default
349
+ # values here (the set values are explicitly mixed in again later), but there is
350
+ # no mixlib-config API to get a Hash back with only the default values.
351
+ #
352
+ # Assumption: since config_file_defaults is the lowest precedence it doesn't matter
353
+ # that we include the set values here, but this is a hack and makes the name of the
354
+ # method a lie. FIXME: make the name not a lie by adding an API to mixlib-config.
355
+ #
356
+ # @api private
357
+ #
358
+ def config_file_defaults
359
+ Chef::Config[:knife].save(true) # this is like "dup" to a (real) Hash, and includes default values (and user set values)
351
360
  end
352
361
 
353
- # extracts the settings from the Chef::Config[:knife] sub-hash that correspond
354
- # to knife cli options -- in preparation for merging config values with cli values
362
+ # This is only the user-set mixlib-config values. We do not include the defaults
363
+ # here so that the config defaults do not override the cli defaults.
364
+ #
365
+ # @api private
355
366
  #
356
- # NOTE: due to weirdness in mixlib-config #has_key? is only true if the value has
357
- # been set by the user -- the Chef::Config defaults return #has_key?() of false and
358
- # this code DEPENDS on that functionality since applying the default values in
359
- # Chef::Config[:knife] would break the defaults in the cli that we would otherwise
360
- # overwrite.
361
367
  def config_file_settings
362
- cli_keys.each_with_object({}) do |key, memo|
363
- if Chef::Config[:knife].key?(key)
364
- memo[key] = Chef::Config[:knife][key]
365
- end
366
- end
368
+ Chef::Config[:knife].save(false) # this is like "dup" to a (real) Hash, and does not include default values (just user set values)
367
369
  end
368
370
 
369
371
  # config is merged in this order (inverse of precedence)
370
- # default_config - mixlib-cli defaults (accessor from the mixin)
371
- # config_file_settings - Chef::Config[:knife] sub-hash
372
- # config - mixlib-cli settings (accessor from the mixin)
372
+ # config_file_defaults - Chef::Config[:knife] defaults from chef-config (XXX: this also includes the settings, but they get overwritten)
373
+ # default_config - mixlib-cli defaults (accessor from mixlib-cli)
374
+ # config_file_settings - Chef::Config[:knife] user settings from the client.rb file
375
+ # config - mixlib-cli settings (accessor from mixlib-cli)
376
+ #
373
377
  def merge_configs
374
378
  # Update our original_config - if someone has created a knife command
375
379
  # instance directly, they are likely ot have set cmd.config values directly
@@ -377,7 +381,7 @@ class Chef
377
381
  @original_config = config.dup
378
382
  # other code may have a handle to the config object, so use Hash#replace to deliberately
379
383
  # update-in-place.
380
- config.replace(default_config.merge(config_file_settings).merge(config))
384
+ config.replace(config_file_defaults.merge(default_config).merge(config_file_settings).merge(config))
381
385
  end
382
386
 
383
387
  #
@@ -387,8 +391,9 @@ class Chef
387
391
  # @return [Symbol,NilClass] return the source of the config key,
388
392
  # one of:
389
393
  # - :cli - this was explicitly provided on the CLI
390
- # - :config - this came from Chef::Config[:knife]
394
+ # - :config - this came from Chef::Config[:knife] explicitly being set
391
395
  # - :cli_default - came from a declared CLI `option`'s `default` value.
396
+ # - :config_default - this came from Chef::Config[:knife]'s defaults
392
397
  # - nil - if the key could not be found in any source.
393
398
  # This can happen when it is invalid, or has been
394
399
  # set directly into #config without then calling #merge_config
@@ -396,6 +401,7 @@ class Chef
396
401
  return :cli if @original_config.include? key
397
402
  return :config if config_file_settings.key? key
398
403
  return :cli_default if default_config.include? key
404
+ return :config_default if config_file_defaults.key? key # must come after :config check
399
405
 
400
406
  nil
401
407
  end
@@ -94,13 +94,13 @@ class Chef
94
94
  description: "For WinRM basic authentication when using the 'ssl' auth method.",
95
95
  boolean: true
96
96
 
97
- # This option was provided in knife bootstrap windows winrm,
98
- # but it is ignored in knife-windows/WinrmSession, and so remains unimplemeneted here.
99
- # option :kerberos_keytab_file,
100
- # :short => "-T KEYTAB_FILE",
101
- # :long => "--keytab-file KEYTAB_FILE",
102
- # :description => "The Kerberos keytab file used for authentication",
103
- # :proc => Proc.new { |keytab| Chef::Config[:knife][:kerberos_keytab_file] = keytab }
97
+ # This option was provided in knife bootstrap windows winrm,
98
+ # but it is ignored in knife-windows/WinrmSession, and so remains unimplemeneted here.
99
+ # option :kerberos_keytab_file,
100
+ # :short => "-T KEYTAB_FILE",
101
+ # :long => "--keytab-file KEYTAB_FILE",
102
+ # :description => "The Kerberos keytab file used for authentication",
103
+ # :proc => Proc.new { |keytab| Chef::Config[:knife][:kerberos_keytab_file] = keytab }
104
104
 
105
105
  option :kerberos_realm,
106
106
  short: "-R KERBEROS_REALM",
@@ -1061,24 +1061,25 @@ class Chef
1061
1061
  }
1062
1062
  end
1063
1063
 
1064
- # Looks up configuration entries, first in the class member
1065
- # `config` which contains options populated from CLI flags.
1066
- # If the entry is not found there, Chef::Config[:knife][KEY]
1067
- # is checked.
1064
+ # Knife plugins should just use the config hash and not call this method. In the
1065
+ # future there will be a way to deprecate Chef::Config options in addition to the
1066
+ # CLI options, which will eliminate this methods primary purpose.
1068
1067
  #
1069
- # knife_config_key should be specified if the knife config lookup
1070
- # key is different from the CLI flag lookup key.
1068
+ # In Chef-16 the single-argument verison of this function will be deprecated and
1069
+ # config_value(:whatver) should be converted to config[:whatever]. That never had
1070
+ # any purpose and never should have been used this way.
1071
1071
  #
1072
- def config_value(key, knife_config_key = nil, default = nil)
1073
- if config.key? key
1072
+ # @api deprecated
1073
+ #
1074
+ def config_value(key, fallback_key = nil, default = nil)
1075
+ if config.key?(key)
1076
+ # the first key is the primary key so we check the merged hash first
1074
1077
  config[key]
1078
+ elsif config.key?(fallback_key)
1079
+ # we get the old config option here (the deprecated cli option shouldn't exist)
1080
+ config[fallback_key]
1075
1081
  else
1076
- lookup_key = knife_config_key || key
1077
- if Chef::Config[:knife].key?(lookup_key) || config.key?(lookup_key)
1078
- Chef::Config[:knife][lookup_key] || config[lookup_key]
1079
- else
1080
- default
1081
- end
1082
+ default
1082
1083
  end
1083
1084
  end
1084
1085
 
@@ -21,7 +21,7 @@ class Chef
21
21
  class ChefVaultHandler
22
22
 
23
23
  # @return [Hash] knife merged config, typically @config
24
- attr_accessor :knife_config
24
+ attr_accessor :config
25
25
 
26
26
  # @return [Chef::Knife::UI] ui object for output
27
27
  attr_accessor :ui
@@ -29,11 +29,15 @@ class Chef
29
29
  # @return [Chef::ApiClient] vault client
30
30
  attr_reader :client
31
31
 
32
- # @param knife_config [Hash] knife merged config, typically @config
32
+ # @param config [Hash] knife merged config, typically @config
33
33
  # @param ui [Chef::Knife::UI] ui object for output
34
- def initialize(knife_config: {}, ui: nil)
35
- @knife_config = knife_config
36
- @ui = ui
34
+ def initialize(config: {}, knife_config: nil, ui: nil)
35
+ @config = config
36
+ unless knife_config.nil?
37
+ # the knife_config argument becomes deprecated in Chef-16, don't use it
38
+ @config = knife_config
39
+ end
40
+ @ui = ui
37
41
  end
38
42
 
39
43
  # Updates the chef vault items for the newly created client.
@@ -85,17 +89,17 @@ class Chef
85
89
 
86
90
  # @return [String] string with serialized JSON representing the chef vault items
87
91
  def bootstrap_vault_json
88
- knife_config[:bootstrap_vault_json]
92
+ config[:bootstrap_vault_json]
89
93
  end
90
94
 
91
95
  # @return [String] JSON text in a file representing the chef vault items
92
96
  def bootstrap_vault_file
93
- knife_config[:bootstrap_vault_file]
97
+ config[:bootstrap_vault_file]
94
98
  end
95
99
 
96
100
  # @return [Hash] Ruby object representing the chef vault items to create
97
101
  def bootstrap_vault_item
98
- knife_config[:bootstrap_vault_item]
102
+ config[:bootstrap_vault_item]
99
103
  end
100
104
 
101
105
  # Helper to return a ruby object represeting all the data bags and items
@@ -28,7 +28,7 @@ class Chef
28
28
  class ClientBuilder
29
29
 
30
30
  # @return [Hash] knife merged config, typically @config
31
- attr_accessor :knife_config
31
+ attr_accessor :config
32
32
  # @return [Hash] chef config object
33
33
  attr_accessor :chef_config
34
34
  # @return [Chef::Knife::UI] ui object for output
@@ -36,13 +36,17 @@ class Chef
36
36
  # @return [Chef::ApiClient] client saved on run
37
37
  attr_reader :client
38
38
 
39
- # @param knife_config [Hash] Hash of knife config settings
39
+ # @param config [Hash] Hash of knife config settings
40
40
  # @param chef_config [Hash] Hash of chef config settings
41
41
  # @param ui [Chef::Knife::UI] UI object for output
42
- def initialize(knife_config: {}, chef_config: {}, ui: nil)
43
- @knife_config = knife_config
44
- @chef_config = chef_config
45
- @ui = ui
42
+ def initialize(config: {}, knife_config: nil, chef_config: {}, ui: nil)
43
+ @config = config
44
+ unless knife_config.nil?
45
+ # the knife_config argument becomes deprecated in Chef-16, don't use it
46
+ @config = knife_config
47
+ end
48
+ @chef_config = chef_config
49
+ @ui = ui
46
50
  end
47
51
 
48
52
  # Main entry. Prompt the user to clean up any old client or node objects. Then create
@@ -77,34 +81,34 @@ class Chef
77
81
 
78
82
  private
79
83
 
80
- # @return [String] node name from the knife_config
84
+ # @return [String] node name from the config
81
85
  def node_name
82
- knife_config[:chef_node_name]
86
+ config[:chef_node_name]
83
87
  end
84
88
 
85
- # @return [String] enviroment from the knife_config
89
+ # @return [String] enviroment from the config
86
90
  def environment
87
- knife_config[:environment]
91
+ config[:environment]
88
92
  end
89
93
 
90
- # @return [String] run_list from the knife_config
94
+ # @return [String] run_list from the config
91
95
  def run_list
92
- knife_config[:run_list]
96
+ config[:run_list]
93
97
  end
94
98
 
95
- # @return [String] policy_name from the knife_config
99
+ # @return [String] policy_name from the config
96
100
  def policy_name
97
- knife_config[:policy_name]
101
+ config[:policy_name]
98
102
  end
99
103
 
100
- # @return [String] policy_group from the knife_config
104
+ # @return [String] policy_group from the config
101
105
  def policy_group
102
- knife_config[:policy_group]
106
+ config[:policy_group]
103
107
  end
104
108
 
105
- # @return [Hash,Array] Object representation of json first-boot attributes from the knife_config
109
+ # @return [Hash,Array] Object representation of json first-boot attributes from the config
106
110
  def first_boot_attributes
107
- knife_config[:first_boot_attributes]
111
+ config[:first_boot_attributes]
108
112
  end
109
113
 
110
114
  # @return [String] chef server url from the Chef::Config
@@ -154,7 +158,7 @@ class Chef
154
158
  node.environment(environment) if environment
155
159
  node.policy_name = policy_name if policy_name
156
160
  node.policy_group = policy_group if policy_group
157
- (knife_config[:tags] || []).each do |tag|
161
+ (config[:tags] || []).each do |tag|
158
162
  node.tags << tag
159
163
  end
160
164
  node