chef 12.16.42-universal-mingw32 → 12.17.44-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/README.md +20 -5
  4. data/Rakefile +17 -0
  5. data/VERSION +1 -1
  6. data/acceptance/Gemfile.lock +32 -23
  7. data/distro/common/markdown/man1/knife-configure.mkd +3 -2
  8. data/lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb +1 -1
  9. data/lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb +1 -1
  10. data/lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +1 -1
  11. data/lib-backcompat/chef/chef_fs/file_system/file_system_error.rb +1 -1
  12. data/lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb +1 -1
  13. data/lib-backcompat/chef/chef_fs/file_system/not_found_error.rb +1 -1
  14. data/lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb +1 -1
  15. data/lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb +1 -1
  16. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +1 -1
  17. data/lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -1
  18. data/lib/chef/api_client.rb +1 -1
  19. data/lib/chef/application.rb +1 -1
  20. data/lib/chef/application/exit_code.rb +3 -3
  21. data/lib/chef/chef_class.rb +15 -5
  22. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +12 -1
  23. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +19 -0
  24. data/lib/chef/client.rb +1 -0
  25. data/lib/chef/cookbook/metadata.rb +2 -2
  26. data/lib/chef/cookbook_version.rb +4 -4
  27. data/lib/chef/data_bag.rb +1 -1
  28. data/lib/chef/data_bag_item.rb +1 -1
  29. data/lib/chef/data_collector.rb +20 -13
  30. data/lib/chef/data_collector/messages.rb +0 -1
  31. data/lib/chef/data_collector/messages/helpers.rb +2 -2
  32. data/lib/chef/decorator/unchain.rb +2 -2
  33. data/lib/chef/deprecated.rb +190 -0
  34. data/lib/chef/deprecation/provider/remote_directory.rb +1 -1
  35. data/lib/chef/deprecation/warnings.rb +3 -4
  36. data/lib/chef/dsl/method_missing.rb +2 -2
  37. data/lib/chef/dsl/resources.rb +2 -2
  38. data/lib/chef/environment.rb +1 -1
  39. data/lib/chef/exceptions.rb +1 -1
  40. data/lib/chef/formatters/base.rb +11 -1
  41. data/lib/chef/formatters/doc.rb +13 -4
  42. data/lib/chef/key.rb +1 -1
  43. data/lib/chef/knife/client_delete.rb +12 -9
  44. data/lib/chef/knife/configure.rb +1 -1
  45. data/lib/chef/knife/core/bootstrap_context.rb +25 -1
  46. data/lib/chef/knife/core/subcommand_loader.rb +3 -3
  47. data/lib/chef/knife/core/ui.rb +1 -1
  48. data/lib/chef/knife/node_delete.rb +6 -6
  49. data/lib/chef/log.rb +1 -1
  50. data/lib/chef/mixin/deprecation.rb +4 -10
  51. data/lib/chef/mixin/powershell_type_coercions.rb +19 -19
  52. data/lib/chef/mixin/shell_out.rb +1 -1
  53. data/lib/chef/node.rb +2 -2
  54. data/lib/chef/node/attribute.rb +3 -4
  55. data/lib/chef/node/common_api.rb +1 -1
  56. data/lib/chef/node/mixin/state_tracking.rb +5 -2
  57. data/lib/chef/node_map.rb +2 -2
  58. data/lib/chef/org.rb +1 -1
  59. data/lib/chef/platform/rebooter.rb +3 -1
  60. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  61. data/lib/chef/property.rb +5 -5
  62. data/lib/chef/provider.rb +4 -4
  63. data/lib/chef/provider/launchd.rb +1 -1
  64. data/lib/chef/provider/link.rb +6 -0
  65. data/lib/chef/provider/mount.rb +2 -0
  66. data/lib/chef/provider/mount/mount.rb +1 -1
  67. data/lib/chef/provider/ohai.rb +5 -3
  68. data/lib/chef/provider/package/cab.rb +1 -1
  69. data/lib/chef/provider/package/chocolatey.rb +2 -2
  70. data/lib/chef/provider/package/easy_install.rb +2 -2
  71. data/lib/chef/provider/package/msu.rb +162 -0
  72. data/lib/chef/provider/package/powershell.rb +114 -0
  73. data/lib/chef/provider/package/yum.rb +1 -1
  74. data/lib/chef/provider/yum_repository.rb +6 -7
  75. data/lib/chef/provider_resolver.rb +2 -2
  76. data/lib/chef/providers.rb +2 -0
  77. data/lib/chef/resource.rb +3 -5
  78. data/lib/chef/resource/apt_update.rb +1 -1
  79. data/lib/chef/resource/chef_gem.rb +2 -3
  80. data/lib/chef/resource/file/verification.rb +1 -1
  81. data/lib/chef/resource/launchd.rb +48 -8
  82. data/lib/chef/resource/mount.rb +1 -1
  83. data/lib/chef/resource/msu_package.rb +47 -0
  84. data/lib/chef/resource/ohai.rb +5 -25
  85. data/lib/chef/resource/powershell_package.rb +41 -0
  86. data/lib/chef/resource/reboot.rb +1 -1
  87. data/lib/chef/resource/user.rb +2 -2
  88. data/lib/chef/resource_builder.rb +4 -4
  89. data/lib/chef/resource_resolver.rb +2 -3
  90. data/lib/chef/resources.rb +2 -0
  91. data/lib/chef/rest.rb +1 -1
  92. data/lib/chef/role.rb +1 -1
  93. data/lib/chef/run_context.rb +3 -3
  94. data/lib/chef/shell/ext.rb +2 -2
  95. data/lib/chef/user.rb +3 -3
  96. data/lib/chef/user_v1.rb +1 -1
  97. data/lib/chef/version.rb +1 -1
  98. data/lib/chef/win32/api/security.rb +12 -12
  99. data/spec/data/sample_msu1.xml +10 -0
  100. data/spec/data/sample_msu2.xml +14 -0
  101. data/spec/data/sample_msu3.xml +16 -0
  102. data/spec/functional/rebooter_spec.rb +3 -3
  103. data/spec/functional/resource/link_spec.rb +62 -1
  104. data/spec/functional/resource/msu_package_spec.rb +84 -0
  105. data/spec/functional/resource/registry_spec.rb +3 -3
  106. data/spec/functional/resource/rpm_spec.rb +7 -10
  107. data/spec/integration/solo/solo_spec.rb +50 -0
  108. data/spec/spec_helper.rb +3 -0
  109. data/spec/support/platform_helpers.rb +16 -8
  110. data/spec/unit/application/exit_code_spec.rb +3 -15
  111. data/spec/unit/data_collector_spec.rb +6 -16
  112. data/spec/unit/deprecated_spec.rb +59 -0
  113. data/spec/unit/deprecation_spec.rb +1 -8
  114. data/spec/unit/handler_spec.rb +2 -2
  115. data/spec/unit/knife/client_delete_spec.rb +16 -0
  116. data/spec/unit/knife/configure_spec.rb +1 -1
  117. data/spec/unit/knife/cookbook_metadata_spec.rb +116 -113
  118. data/spec/unit/knife/core/bootstrap_context_spec.rb +55 -5
  119. data/spec/unit/knife/node_delete_spec.rb +19 -10
  120. data/spec/unit/mixin/shell_out_spec.rb +0 -1
  121. data/spec/unit/node/immutable_collections_spec.rb +5 -0
  122. data/spec/unit/node/vivid_mash_spec.rb +11 -0
  123. data/spec/unit/node_spec.rb +2 -2
  124. data/spec/unit/provider/launchd_spec.rb +81 -3
  125. data/spec/unit/provider/mount/mount_spec.rb +1 -1
  126. data/spec/unit/provider/mount_spec.rb +7 -0
  127. data/spec/unit/provider/package/chocolatey_spec.rb +5 -5
  128. data/spec/unit/provider/package/easy_install_spec.rb +6 -6
  129. data/spec/unit/provider/package/msu_spec.rb +283 -0
  130. data/spec/unit/provider/package/powershell_spec.rb +337 -0
  131. data/spec/unit/provider/service/macosx_spec.rb +1 -1
  132. data/spec/unit/provider/subversion_spec.rb +9 -0
  133. data/spec/unit/provider/user/linux_spec.rb +7 -1
  134. data/spec/unit/recipe_spec.rb +43 -11
  135. data/spec/unit/resource/apt_update_spec.rb +17 -25
  136. data/spec/unit/resource/file/verification_spec.rb +1 -1
  137. data/spec/unit/resource/mount_spec.rb +2 -1
  138. data/spec/unit/resource/msu_package_spec.rb +49 -0
  139. data/spec/unit/resource/ohai_spec.rb +1 -1
  140. data/spec/unit/resource/powershell_package_spec.rb +68 -0
  141. data/spec/unit/resource_reporter_spec.rb +4 -4
  142. data/spec/unit/run_status_spec.rb +1 -1
  143. data/tasks/announce.rb +58 -0
  144. data/tasks/changelog.rb +26 -6
  145. data/tasks/templates/prerelease.md.erb +35 -0
  146. data/tasks/templates/release.md.erb +34 -0
  147. metadata +21 -4
@@ -37,7 +37,7 @@ class Chef
37
37
  # method_missing manually. Not a fan. Not. A. Fan.
38
38
  #
39
39
  if respond_to?(method_symbol)
40
- Chef.log_deprecation("Calling method_missing(#{method_symbol.inspect}) directly is deprecated in Chef 12 and will be removed in Chef 13. Use public_send() or send() instead.")
40
+ Chef.deprecated(:internal_api, "Calling method_missing(#{method_symbol.inspect}) directly is deprecated in Chef 12 and will be removed in Chef 13. Use public_send() or send() instead.")
41
41
  return send(method_symbol, *args, &block)
42
42
  end
43
43
 
@@ -46,7 +46,7 @@ class Chef
46
46
  # never called. DEPRECATED.
47
47
  #
48
48
  if run_context.definitions.has_key?(method_symbol.to_sym)
49
- Chef.log_deprecation("Definition #{method_symbol} (#{run_context.definitions[method_symbol.to_sym]}) was added to the run_context without calling Chef::DSL::Definitions.add_definition(#{method_symbol.to_sym.inspect}). This will become required in Chef 13.")
49
+ Chef.deprecated(:internal_api, "Definition #{method_symbol} (#{run_context.definitions[method_symbol.to_sym]}) was added to the run_context without calling Chef::DSL::Definitions.add_definition(#{method_symbol.to_sym.inspect}). This will become required in Chef 13.")
50
50
  Chef::DSL::Definitions.add_definition(method_symbol)
51
51
  return send(method_symbol, *args, &block)
52
52
  end
@@ -36,14 +36,14 @@ class Chef
36
36
  begin
37
37
  module_eval(<<-EOM, __FILE__, __LINE__ + 1)
38
38
  def #{dsl_name}(*args, &block)
39
- Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1
39
+ Chef.deprecated(:internal_api, "Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1
40
40
  declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block)
41
41
  end
42
42
  EOM
43
43
  rescue SyntaxError
44
44
  # Handle the case where dsl_name has spaces, etc.
45
45
  define_method(dsl_name.to_sym) do |*args, &block|
46
- Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: #{args}") if args.size > 1
46
+ Chef.deprecated(:internal_api, "Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: #{args}") if args.size > 1
47
47
  declare_resource(dsl_name, args[0], caller[0], &block)
48
48
  end
49
49
  end
@@ -217,7 +217,7 @@ class Chef
217
217
  end
218
218
 
219
219
  def self.json_create(o)
220
- Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Environment#from_hash")
220
+ Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Environment#from_hash")
221
221
  from_hash(o)
222
222
  end
223
223
 
@@ -262,7 +262,7 @@ class Chef
262
262
 
263
263
  class ChildConvergeError < RuntimeError; end
264
264
 
265
- class DeprecatedFeatureError < RuntimeError;
265
+ class DeprecatedFeatureError < RuntimeError
266
266
  def initalize(message)
267
267
  super("#{message} (raising error due to treat_deprecation_warnings_as_errors being set)")
268
268
  end
@@ -213,7 +213,17 @@ class Chef
213
213
  end
214
214
 
215
215
  def deprecation(message, location = caller(2..2)[0])
216
- Chef::Log.deprecation("#{message} at #{location}")
216
+ out = if is_structured_deprecation?(message)
217
+ message.inspect
218
+ else
219
+ "#{message} at #{location}"
220
+ end
221
+
222
+ Chef::Log.deprecation(out)
223
+ end
224
+
225
+ def is_structured_deprecation?(deprecation)
226
+ deprecation.kind_of?(Chef::Deprecated::Base)
217
227
  end
218
228
 
219
229
  def is_formatter?
@@ -61,9 +61,10 @@ class Chef
61
61
  if !deprecations.empty?
62
62
  puts_line ""
63
63
  puts_line "Deprecated features used!"
64
- deprecations.each do |message, locations|
64
+ deprecations.each do |message, details|
65
+ locations = details[:locations]
65
66
  if locations.size == 1
66
- puts_line " #{message} at #{locations.size} location:"
67
+ puts_line " #{message} at 1 location:"
67
68
  else
68
69
  puts_line " #{message} at #{locations.size} locations:"
69
70
  end
@@ -74,6 +75,9 @@ class Chef
74
75
  prefix = " "
75
76
  end
76
77
  end
78
+ unless details[:url].nil?
79
+ puts_line " See #{details[:url]} for further details."
80
+ end
77
81
  end
78
82
  puts_line ""
79
83
  end
@@ -416,8 +420,13 @@ class Chef
416
420
  end
417
421
 
418
422
  # Save deprecations to the screen until the end
419
- deprecations[message] ||= Set.new
420
- deprecations[message] << location
423
+ if is_structured_deprecation?(message)
424
+ url = message.url
425
+ message = message.message
426
+ end
427
+
428
+ deprecations[message] ||= { url: url, locations: Set.new }
429
+ deprecations[message][:locations] << location
421
430
  end
422
431
 
423
432
  def indent
@@ -223,7 +223,7 @@ class Chef
223
223
  end
224
224
 
225
225
  def json_create(json)
226
- Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Key#from_json or one of the load_by methods.")
226
+ Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Key#from_json or one of the load_by methods.")
227
227
  Chef::Key.from_json(json)
228
228
  end
229
229
 
@@ -32,29 +32,32 @@ class Chef
32
32
  :long => "--delete-validators",
33
33
  :description => "Force deletion of client if it's a validator"
34
34
 
35
- banner "knife client delete CLIENT (options)"
35
+ banner "knife client delete [CLIENT[,CLIENT]] (options)"
36
36
 
37
37
  def run
38
- @client_name = @name_args[0]
39
-
40
- if @client_name.nil?
38
+ if @name_args.length == 0
41
39
  show_usage
42
- ui.fatal("You must specify a client name")
40
+ ui.fatal("You must specify at least one client name")
43
41
  exit 1
44
42
  end
45
43
 
46
- delete_object(Chef::ApiClientV1, @client_name, "client") do
47
- object = Chef::ApiClientV1.load(@client_name)
44
+ @name_args.each do |client_name|
45
+ delete_client(client_name)
46
+ end
47
+ end
48
+
49
+ def delete_client(client_name)
50
+ delete_object(Chef::ApiClientV1, client_name, "client") do
51
+ object = Chef::ApiClientV1.load(client_name)
48
52
  if object.validator
49
53
  unless config[:delete_validators]
50
- ui.fatal("You must specify --delete-validators to delete the validator client #{@client_name}")
54
+ ui.fatal("You must specify --delete-validators to delete the validator client #{client_name}")
51
55
  exit 2
52
56
  end
53
57
  end
54
58
  object.destroy
55
59
  end
56
60
  end
57
-
58
61
  end
59
62
  end
60
63
  end
@@ -133,7 +133,7 @@ EOH
133
133
 
134
134
  def ask_user_for_config
135
135
  server_name = guess_servername
136
- @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "https://#{server_name}:443")
136
+ @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "https://#{server_name}/organizations/myorg")
137
137
  if config[:initial]
138
138
  @new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", :default => Etc.getlogin)
139
139
  @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", :default => "admin")
@@ -67,12 +67,36 @@ class Chef
67
67
  @trusted_certs ||= trusted_certs_content
68
68
  end
69
69
 
70
+ def get_log_location
71
+ if !(@chef_config[:config_log_location].class == IO ) && (@chef_config[:config_log_location].nil? || @chef_config[:config_log_location].to_s.empty?)
72
+ "STDOUT"
73
+ elsif @chef_config[:config_log_location].equal?(:win_evt)
74
+ raise "The value :win_evt is not supported for config_log_location on Linux Platforms \n"
75
+ elsif @chef_config[:config_log_location].equal?(:syslog)
76
+ ":syslog"
77
+ elsif @chef_config[:config_log_location].equal?(STDOUT)
78
+ "STDOUT"
79
+ elsif @chef_config[:config_log_location].equal?(STDERR)
80
+ "STDERR"
81
+ elsif @chef_config[:config_log_location]
82
+ %Q{"#{@chef_config[:config_log_location]}"}
83
+ else
84
+ "STDOUT"
85
+ end
86
+ end
87
+
70
88
  def config_content
71
89
  client_rb = <<-CONFIG
72
- log_location STDOUT
73
90
  chef_server_url "#{@chef_config[:chef_server_url]}"
74
91
  validation_client_name "#{@chef_config[:validation_client_name]}"
75
92
  CONFIG
93
+
94
+ if !(@chef_config[:config_log_level].nil? || @chef_config[:config_log_level].empty?)
95
+ client_rb << %Q{log_level :#{@chef_config[:config_log_level]}\n}
96
+ end
97
+
98
+ client_rb << "log_location #{get_log_location}\n"
99
+
76
100
  if @config[:chef_node_name]
77
101
  client_rb << %Q{node_name "#{@config[:chef_node_name]}"\n}
78
102
  else
@@ -51,7 +51,7 @@ class Chef
51
51
  Chef::Log.debug("Using autogenerated hashed command manifest #{plugin_manifest_path}")
52
52
  Knife::SubcommandLoader::HashedCommandLoader.new(chef_config_dir, plugin_manifest)
53
53
  elsif custom_manifest?
54
- Chef.log_deprecation("Using custom manifest #{plugin_manifest_path} is deprecated. Please use a `knife rehash` autogenerated manifest instead.")
54
+ Chef.deprecated(:internal_api, "Using custom manifest #{plugin_manifest_path} is deprecated. Please use a `knife rehash` autogenerated manifest instead.")
55
55
  Knife::SubcommandLoader::CustomManifestLoader.new(chef_config_dir, plugin_manifest)
56
56
  else
57
57
  Knife::SubcommandLoader::GemGlobLoader.new(chef_config_dir)
@@ -90,7 +90,7 @@ class Chef
90
90
  # Deprecated and un-used instance variable.
91
91
  @env = env
92
92
  unless env.nil?
93
- Chef.log_deprecation("The env argument to Chef::Knife::SubcommandLoader is deprecated. If you are using env to inject/mock HOME, consider mocking Chef::Util::PathHelper.home instead.")
93
+ Chef.deprecated(:internal_api, "The env argument to Chef::Knife::SubcommandLoader is deprecated. If you are using env to inject/mock HOME, consider mocking Chef::Util::PathHelper.home instead.")
94
94
  end
95
95
  end
96
96
 
@@ -154,7 +154,7 @@ class Chef
154
154
  # to get in the past.
155
155
  #
156
156
  def subcommand_files
157
- Chef.log_deprecation "Using Chef::Knife::SubcommandLoader directly is deprecated.
157
+ Chef.deprecated :internal_api, "Using Chef::Knife::SubcommandLoader directly is deprecated.
158
158
  Please use Chef::Knife::SubcommandLoader.for_config(chef_config_dir, env)"
159
159
  @subcommand_files ||= if Chef::Knife::SubcommandLoader.plugin_manifest?
160
160
  Chef::Knife::SubcommandLoader::CustomManifestLoader.new(chef_config_dir, env).subcommand_files
@@ -186,7 +186,7 @@ class Chef
186
186
 
187
187
  if parse_output
188
188
  if object_class.nil?
189
- Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please pass in the class to inflate or use #edit_hash")
189
+ Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please pass in the class to inflate or use #edit_hash")
190
190
  Chef::JSONCompat.from_json(output)
191
191
  else
192
192
  object_class.from_hash(Chef::JSONCompat.parse(output))
@@ -27,18 +27,18 @@ class Chef
27
27
  require "chef/json_compat"
28
28
  end
29
29
 
30
- banner "knife node delete NODE (options)"
30
+ banner "knife node delete [NODE[,NODE]] (options)"
31
31
 
32
32
  def run
33
- @node_name = @name_args[0]
34
-
35
- if @node_name.nil?
33
+ if @name_args.length == 0
36
34
  show_usage
37
- ui.fatal("You must specify a node name")
35
+ ui.fatal("You must specify at least one node name")
38
36
  exit 1
39
37
  end
40
38
 
41
- delete_object(Chef::Node, @node_name)
39
+ @name_args.each do |node_name|
40
+ delete_object(Chef::Node, node_name)
41
+ end
42
42
  end
43
43
 
44
44
  end
@@ -58,7 +58,7 @@ class Chef
58
58
  end
59
59
  if Chef::Config[:treat_deprecation_warnings_as_errors]
60
60
  error(msg, &block)
61
- raise Chef::Exceptions::DeprecatedFeatureError.new(msg)
61
+ raise Chef::Exceptions::DeprecatedFeatureError.new(msg.inspect)
62
62
  else
63
63
  warn(msg, &block)
64
64
  end
@@ -65,7 +65,7 @@ class Chef
65
65
  end
66
66
 
67
67
  def method_missing(method_name, *args, &block)
68
- log_deprecation_msg(caller[0..3])
68
+ deprecated_msg(caller[0..3])
69
69
  @target.send(method_name, *args, &block)
70
70
  end
71
71
 
@@ -75,7 +75,7 @@ class Chef
75
75
 
76
76
  private
77
77
 
78
- def log_deprecation_msg(*called_from)
78
+ def deprecated_msg(*called_from)
79
79
  called_from = called_from.flatten
80
80
  log("Accessing #{@ivar_name} by the variable @#{@ivar_name} is deprecated. Support will be removed in a future release.")
81
81
  log("Please update your cookbooks to use #{@ivar_name} in place of @#{@ivar_name}. Accessed from:")
@@ -101,20 +101,14 @@ class Chef
101
101
 
102
102
  def deprecated_attr_reader(name, alternative, level = :warn)
103
103
  define_method(name) do
104
- Chef.log_deprecation("#{self.class}.#{name} is deprecated. Support will be removed in a future release.")
105
- Chef.log_deprecation(alternative)
106
- Chef.log_deprecation("Called from:")
107
- caller[0..3].each { |c| Chef.log_deprecation(c) }
104
+ Chef.deprecated(:internal_api, "#{self.class}.#{name} is deprecated. Support will be removed in a future release. #{alternative}")
108
105
  instance_variable_get("@#{name}")
109
106
  end
110
107
  end
111
108
 
112
109
  def deprecated_attr_writer(name, alternative, level = :warn)
113
110
  define_method("#{name}=") do |value|
114
- Chef.log_deprecation("Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release.")
115
- Chef.log_deprecation(alternative)
116
- Chef.log_deprecation("Called from:")
117
- caller[0..3].each { |c| Chef.log_deprecation(c) }
111
+ Chef.deprecated(:internal_api, "Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release. #{alternative}")
118
112
  instance_variable_set("@#{name}", value)
119
113
  end
120
114
  end
@@ -21,31 +21,31 @@ class Chef
21
21
  module Mixin
22
22
  module PowershellTypeCoercions
23
23
 
24
- def type_coercions
25
- @type_coercions ||= {
26
- Fixnum => { :type => lambda { |x| x.to_s } },
27
- Float => { :type => lambda { |x| x.to_s } },
28
- FalseClass => { :type => lambda { |x| "$false" } },
29
- TrueClass => { :type => lambda { |x| "$true" } },
30
- Hash => { :type => Proc.new { |x| translate_hash(x) } },
31
- Array => { :type => Proc.new { |x| translate_array(x) } },
32
- Chef::Node::ImmutableMash => { :type => Proc.new { |x| translate_hash(x) } },
33
- Chef::Node::ImmutableArray => { :type => Proc.new { |x| translate_array(x) } },
34
- }
24
+ def type_coercion(value)
25
+ case value
26
+ when Integer, Float
27
+ value.to_s
28
+ when FalseClass
29
+ "$false"
30
+ when TrueClass
31
+ "$true"
32
+ when Hash, Chef::Node::ImmutableMash
33
+ translate_hash(value)
34
+ when Array, Chef::Node::ImmutableArray
35
+ translate_array(value)
36
+ end
35
37
  end
36
38
 
37
- def translate_type(value)
38
- translation = type_coercions[value.class]
39
-
40
- if translation
41
- translation[:type].call(value)
42
- elsif value.respond_to? :to_psobject
39
+ def psobject_conversion(value)
40
+ if value.respond_to?(:to_psobject)
43
41
  "(#{value.to_psobject})"
44
- else
45
- safe_string(value.to_s)
46
42
  end
47
43
  end
48
44
 
45
+ def translate_type(value)
46
+ type_coercion(value) || psobject_conversion(value) || safe_string(value.to_s)
47
+ end
48
+
49
49
  private
50
50
 
51
51
  def translate_hash(x)
@@ -118,7 +118,7 @@ class Chef
118
118
  end
119
119
 
120
120
  def deprecate_option(old_option, new_option)
121
- Chef.log_deprecation "DEPRECATION: Chef::Mixin::ShellOut option :#{old_option} is deprecated. Use :#{new_option}"
121
+ Chef.deprecated :internal_api, "Chef::Mixin::ShellOut option :#{old_option} is deprecated. Use :#{new_option}"
122
122
  end
123
123
 
124
124
  def io_for_live_stream
@@ -201,7 +201,7 @@ class Chef
201
201
  end
202
202
 
203
203
  def set
204
- Chef.log_deprecation("node.set is deprecated and will be removed in Chef 14, please use node.default/node.override (or node.normal only if you really need persistence)")
204
+ Chef.deprecated(:attributes, "node.set is deprecated and will be removed in Chef 14, please use node.default/node.override (or node.normal only if you really need persistence)")
205
205
  normal
206
206
  end
207
207
 
@@ -509,7 +509,7 @@ class Chef
509
509
 
510
510
  # Create a Chef::Node from JSON
511
511
  def self.json_create(o)
512
- Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Node#from_hash")
512
+ Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Node#from_hash")
513
513
  from_hash(o)
514
514
  end
515
515
 
@@ -430,7 +430,7 @@ class Chef
430
430
  end
431
431
 
432
432
  def set_unless(*args)
433
- Chef.log_deprecation("node.set_unless is deprecated and will be removed in Chef 14, please use node.default_unless/node.override_unless (or node.normal_unless if you really need persistence)")
433
+ Chef.deprecated(:attributes, "node.set_unless is deprecated and will be removed in Chef 14, please use node.default_unless/node.override_unless (or node.normal_unless if you really need persistence)")
434
434
  return Decorator::Unchain.new(self, :default_unless) unless args.length > 0
435
435
  write(:normal, *args) if read(*args[0...-1]).nil?
436
436
  end
@@ -481,15 +481,14 @@ class Chef
481
481
  if symbol == :to_ary
482
482
  merged_attributes.send(symbol, *args)
483
483
  elsif args.empty?
484
- puts symbol
485
- Chef.log_deprecation %q{method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]["bar"])}
484
+ Chef.deprecated(:attributes, %q{method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]["bar"])})
486
485
  if key?(symbol)
487
486
  self[symbol]
488
487
  else
489
488
  raise NoMethodError, "Undefined method or attribute `#{symbol}' on `node'"
490
489
  end
491
490
  elsif symbol.to_s =~ /=$/
492
- Chef.log_deprecation %q{method setting of node attributes (node.foo="bar") is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]="bar")}
491
+ Chef.deprecated(:attributes, %q{method setting of node attributes (node.foo="bar") is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]="bar")})
493
492
  key_to_set = symbol.to_s[/^(.+)=$/, 1]
494
493
  self[key_to_set] = (args.length == 1 ? args[0] : args)
495
494
  else
@@ -24,7 +24,7 @@ class Chef
24
24
  # method-style access to attributes
25
25
 
26
26
  def valid_container?(obj, key)
27
- return obj.is_a?(Hash) || (obj.is_a?(Array) && key.is_a?(Fixnum))
27
+ return obj.is_a?(Hash) || (obj.is_a?(Array) && key.is_a?(Integer))
28
28
  end
29
29
 
30
30
  private :valid_container?
@@ -34,14 +34,17 @@ class Chef
34
34
  @__precedence__ = precedence
35
35
  end
36
36
 
37
- def [](key)
37
+ def [](*args)
38
38
  ret = super
39
+ key = args.first
39
40
  next_path = [ __path__, convert_key(key) ].flatten.compact
40
41
  copy_state_to(ret, next_path)
41
42
  end
42
43
 
43
- def []=(key, value)
44
+ def []=(*args)
44
45
  ret = super
46
+ key = args.first
47
+ value = args.last
45
48
  next_path = [ __path__, convert_key(key) ].flatten.compact
46
49
  send_attribute_changed_event(next_path, value)
47
50
  copy_state_to(ret, next_path)