summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-01 13:21:02 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-01 19:30:51 -0700
commitf975355dc9cb9ef73ff86471a32bfac459efeb7a (patch)
tree32b4254108a03359934d1da1a4e7e7822086ab87
parent386468df5441f4a75865bccfd9314f883e5f39ff (diff)
downloadchef-f975355dc9cb9ef73ff86471a32bfac459efeb7a.tar.gz
Rename log.deprecation to log_deprecation
-rw-r--r--lib/chef/application.rb2
-rw-r--r--lib/chef/chef_class.rb27
-rw-r--r--lib/chef/cookbook_version.rb6
-rw-r--r--lib/chef/deprecation/warnings.rb2
-rw-r--r--lib/chef/dsl/recipe.rb4
-rw-r--r--lib/chef/dsl/resources.rb4
-rw-r--r--lib/chef/knife/core/subcommand_loader.rb6
-rw-r--r--lib/chef/mixin/deprecation.rb16
-rw-r--r--lib/chef/node_map.rb4
-rw-r--r--lib/chef/property.rb2
-rw-r--r--lib/chef/provider.rb2
-rw-r--r--lib/chef/provider_resolver.rb4
-rw-r--r--lib/chef/resource.rb6
-rw-r--r--lib/chef/resource/chef_gem.rb6
-rw-r--r--lib/chef/resource/file/verification.rb2
-rw-r--r--lib/chef/resource_resolver.rb6
-rw-r--r--lib/chef/run_context.rb8
17 files changed, 57 insertions, 50 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index f43b6bbd8d..970544c068 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -382,7 +382,7 @@ class Chef
def emit_warnings
if Chef::Config[:chef_gem_compile_time]
- Chef.log.deprecation "setting chef_gem_compile_time to true is deprecated"
+ Chef.log_deprecation "setting chef_gem_compile_time to true is deprecated"
end
end
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index e825bedb34..c2cb9e2b24 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -192,19 +192,26 @@ class Chef
end
#
- # @overload log
- # Get the current log object.
+ # Emit a deprecation message.
#
- # @return An object that supports `deprecation(message)`
+ # @param message The message to send.
+ # @param location The location. Defaults to the caller who called you (since
+ # generally the person who triggered the check is the one that needs to be
+ # fixed).
#
# @example
- # run_context.log.deprecation("Deprecated!")
- #
- # @api private
- def log
- # `run_context.events` is the primary deprecation target if we're in a run. If we
- # are not yet in a run, print to `Chef::Log`.
- (run_context && run_context.events) || Chef::Log
+ # Chef.deprecation("Deprecated!")
+ #
+ # @api private this will likely be removed in favor of an as-yet unwritten
+ # `Chef.log`
+ def log_deprecation(message, location=caller(2..2)[0])
+ # `run_context.events` is the primary deprecation target if we're in a
+ # run. If we are not yet in a run, print to `Chef::Log`.
+ if run_context && run_context.events
+ run_context.events.deprecation(message, location)
+ else
+ Chef::Log.deprecation(message, location)
+ end
end
end
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 0a7e1df2f7..bff3146572 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -51,12 +51,12 @@ class Chef
attr_accessor :metadata_filenames
def status=(new_status)
- Chef.log.deprecation("Deprecated method `status' called. This method will be removed.", caller(1..1))
+ Chef.log_deprecation("Deprecated method `status' called. This method will be removed.", caller(1..1))
@status = new_status
end
def status
- Chef.log.deprecation("Deprecated method `status' called. This method will be removed.", caller(1..1))
+ Chef.log_deprecation("Deprecated method `status' called. This method will be removed.", caller(1..1))
@status
end
@@ -480,7 +480,7 @@ class Chef
# @deprecated This method was used by the Ruby Chef Server and is no longer
# needed. There is no replacement.
def generate_manifest_with_urls(&url_generator)
- Chef.log.deprecation("Deprecated method #generate_manifest_with_urls.", caller(1..1))
+ Chef.log_deprecation("Deprecated method #generate_manifest_with_urls.", caller(1..1))
rendered_manifest = manifest.dup
COOKBOOK_SEGMENTS.each do |segment|
diff --git a/lib/chef/deprecation/warnings.rb b/lib/chef/deprecation/warnings.rb
index d6a9cbe374..376629710e 100644
--- a/lib/chef/deprecation/warnings.rb
+++ b/lib/chef/deprecation/warnings.rb
@@ -27,7 +27,7 @@ class Chef
message = []
message << "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef 13."
message << "Please update your cookbooks accordingly."
- Chef.log.deprecation(message, caller(0..3))
+ Chef.log_deprecation(message, caller(0..3))
super(*args)
end
end
diff --git a/lib/chef/dsl/recipe.rb b/lib/chef/dsl/recipe.rb
index e3b91a7eab..26c0ec6768 100644
--- a/lib/chef/dsl/recipe.rb
+++ b/lib/chef/dsl/recipe.rb
@@ -140,7 +140,7 @@ class Chef
# method_missing manually. Not a fan. Not. A. Fan.
#
if respond_to?(method_symbol)
- 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.")
+ 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.")
return send(method_symbol, *args, &block)
end
@@ -149,7 +149,7 @@ class Chef
# never called. DEPRECATED.
#
if run_context.definitions.has_key?(method_symbol.to_sym)
- 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.")
+ 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.")
Chef::DSL::Definitions.add_definition(method_symbol)
return send(method_symbol, *args, &block)
end
diff --git a/lib/chef/dsl/resources.rb b/lib/chef/dsl/resources.rb
index 8e75223b0d..49588ed516 100644
--- a/lib/chef/dsl/resources.rb
+++ b/lib/chef/dsl/resources.rb
@@ -11,14 +11,14 @@ class Chef
begin
module_eval(<<-EOM, __FILE__, __LINE__+1)
def #{dsl_name}(*args, &block)
- 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
+ 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
declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block)
end
EOM
rescue SyntaxError
# Handle the case where dsl_name has spaces, etc.
define_method(dsl_name.to_sym) do |*args, &block|
- 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
+ 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
declare_resource(dsl_name, args[0], caller[0], &block)
end
end
diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb
index 646a75a21c..808e053c40 100644
--- a/lib/chef/knife/core/subcommand_loader.rb
+++ b/lib/chef/knife/core/subcommand_loader.rb
@@ -51,7 +51,7 @@ class Chef
Chef::Log.debug("Using autogenerated hashed command manifest #{plugin_manifest_path}")
Knife::SubcommandLoader::HashedCommandLoader.new(chef_config_dir, plugin_manifest)
elsif custom_manifest?
- Chef.log.deprecation("Using custom manifest #{plugin_manifest_path} is deprecated. Please use a `knife rehash` autogenerated manifest instead.")
+ Chef.log_deprecation("Using custom manifest #{plugin_manifest_path} is deprecated. Please use a `knife rehash` autogenerated manifest instead.")
Knife::SubcommandLoader::CustomManifestLoader.new(chef_config_dir, plugin_manifest)
else
Knife::SubcommandLoader::GemGlobLoader.new(chef_config_dir)
@@ -84,7 +84,7 @@ class Chef
# Deprecated and un-used instance variable.
@env = env
unless env.nil?
- 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.")
+ 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.")
end
end
@@ -149,7 +149,7 @@ class Chef
# to get in the past.
#
def subcommand_files
- Chef.log.deprecation "Using Chef::Knife::SubcommandLoader directly is deprecated.
+ Chef.log_deprecation "Using Chef::Knife::SubcommandLoader directly is deprecated.
Please use Chef::Knife::SubcommandLoader.for_config(chef_config_dir, env)"
@subcommand_files ||= if Chef::Knife::SubcommandLoader.plugin_manifest?
Chef::Knife::SubcommandLoader::CustomManifestLoader.new(chef_config_dir, env).subcommand_files
diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb
index c90daee4f5..562af541bd 100644
--- a/lib/chef/mixin/deprecation.rb
+++ b/lib/chef/mixin/deprecation.rb
@@ -102,20 +102,20 @@ class Chef
def deprecated_attr_reader(name, alternative, level=:warn)
define_method(name) do
- Chef.log.deprecation("#{self.class}.#{name} is deprecated. Support will be removed in a future release.")
- Chef.log.deprecation(alternative)
- Chef.log.deprecation("Called from:")
- caller[0..3].each {|c| Chef.log.deprecation(c)}
+ Chef.log_deprecation("#{self.class}.#{name} is deprecated. Support will be removed in a future release.")
+ Chef.log_deprecation(alternative)
+ Chef.log_deprecation("Called from:")
+ caller[0..3].each {|c| Chef.log_deprecation(c)}
instance_variable_get("@#{name}")
end
end
def deprecated_attr_writer(name, alternative, level=:warn)
define_method("#{name}=") do |value|
- Chef.log.deprecation("Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release.")
- Chef.log.deprecation(alternative)
- Chef.log.deprecation("Called from:")
- caller[0..3].each {|c| Chef.log.deprecation(c)}
+ Chef.log_deprecation("Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release.")
+ Chef.log_deprecation(alternative)
+ Chef.log_deprecation("Called from:")
+ caller[0..3].each {|c| Chef.log_deprecation(c)}
instance_variable_set("@#{name}", value)
end
end
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index 2e62054b80..751f9576f6 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -32,8 +32,8 @@ class Chef
# @return [NodeMap] Returns self for possible chaining
#
def set(key, value, platform: nil, platform_version: nil, platform_family: nil, os: nil, on_platform: nil, on_platforms: nil, canonical: nil, override: nil, &block)
- Chef.log.deprecation("The on_platform option to node_map has been deprecated") if on_platform
- Chef.log.deprecation("The on_platforms option to node_map has been deprecated") if on_platforms
+ Chef.log_deprecation("The on_platform option to node_map has been deprecated") if on_platform
+ Chef.log_deprecation("The on_platforms option to node_map has been deprecated") if on_platforms
platform ||= on_platform || on_platforms
filters = {}
filters[:platform] = platform if platform
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index ccdc711698..09198d90f1 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -228,7 +228,7 @@ class Chef
if value.nil? && !explicitly_accepts_nil?(resource)
# If you say "my_property nil" and the property explicitly accepts
# nil values, we consider this a get.
- Chef.log.deprecation("#{name} nil currently does not overwrite the value of #{name}. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using \"property :#{name}, [MyType, nil]\", or stop setting this value to nil.")
+ Chef.log_deprecation("#{name} nil currently does not overwrite the value of #{name}. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using \"property :#{name}, [MyType, nil]\", or stop setting this value to nil.")
return get(resource)
end
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 5f2430e26e..3138704a55 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -421,7 +421,7 @@ class Chef
module DeprecatedLWRPClass
def const_missing(class_name)
if deprecated_constants[class_name.to_sym]
- Chef.log.deprecation("Using an LWRP provider by its name (#{class_name}) directly is no longer supported in Chef 12 and will be removed. Use Chef::ProviderResolver.new(node, resource, action) instead.")
+ Chef.log_deprecation("Using an LWRP provider by its name (#{class_name}) directly is no longer supported in Chef 12 and will be removed. Use Chef::ProviderResolver.new(node, resource, action) instead.")
deprecated_constants[class_name.to_sym]
else
raise NameError, "uninitialized constant Chef::Provider::#{class_name}"
diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb
index 113b1081ee..82a24fc078 100644
--- a/lib/chef/provider_resolver.rb
+++ b/lib/chef/provider_resolver.rb
@@ -157,8 +157,8 @@ class Chef
# perf concern otherwise.)
handlers = providers.select { |handler| overrode_provides?(handler) && handler.provides?(node, resource) }
handlers.each do |handler|
- Chef.log.deprecation("#{handler}.provides? returned true when asked if it provides DSL #{resource.resource_name}, but provides #{resource.resource_name.inspect} was never called!")
- Chef.log.deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
+ Chef.log_deprecation("#{handler}.provides? returned true when asked if it provides DSL #{resource.resource_name}, but provides #{resource.resource_name.inspect} was never called!")
+ Chef.log_deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
end
end
handlers
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 6b8c5434f5..ee75dec3b9 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -809,7 +809,7 @@ class Chef
end
if !options[:default].frozen? && (options[:default].is_a?(Array) || options[:default].is_a?(Hash))
- Chef.log.deprecation("Property #{self}.#{name} has an array or hash default (#{options[:default]}). This means that if one resource modifies or appends to it, all other resources of the same type will also see the changes. Either freeze the constant with `.freeze` to prevent appending, or use lazy { #{options[:default].inspect} }.")
+ Chef.log_deprecation("Property #{self}.#{name} has an array or hash default (#{options[:default]}). This means that if one resource modifies or appends to it, all other resources of the same type will also see the changes. Either freeze the constant with `.freeze` to prevent appending, or use lazy { #{options[:default].inspect} }.")
end
local_properties = properties(false)
@@ -1211,7 +1211,7 @@ class Chef
# @deprecated Use resource_name instead.
#
def self.dsl_name
- Chef.log.deprecation "Resource.dsl_name is deprecated and will be removed in Chef 13. Use resource_name instead."
+ Chef.log_deprecation "Resource.dsl_name is deprecated and will be removed in Chef 13. Use resource_name instead."
if name
name = self.name.split('::')[-1]
convert_to_snake_case(name)
@@ -1288,7 +1288,7 @@ class Chef
#
def self.provider_base(arg=nil)
if arg
- Chef.log.deprecation("Resource.provider_base is deprecated and will be removed in Chef 13. Use provides on the provider, or provider on the resource, instead.")
+ Chef.log_deprecation("Resource.provider_base is deprecated and will be removed in Chef 13. Use provides on the provider, or provider on the resource, instead.")
end
@provider_base ||= arg || Chef::Provider
end
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb
index 4d198421ce..7e9d21ebd2 100644
--- a/lib/chef/resource/chef_gem.rb
+++ b/lib/chef/resource/chef_gem.rb
@@ -50,9 +50,9 @@ class Chef
# Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled
# Action could be an array of symbols, but probably won't (think install + enable for a package)
if compile_time.nil?
- Chef.log.deprecation "#{self} chef_gem compile_time installation is deprecated"
- Chef.log.deprecation "#{self} Please set `compile_time false` on the resource to use the new behavior."
- Chef.log.deprecation "#{self} or set `compile_time true` on the resource if compile_time behavior is required."
+ Chef.log_deprecation "#{self} chef_gem compile_time installation is deprecated"
+ Chef.log_deprecation "#{self} Please set `compile_time false` on the resource to use the new behavior."
+ Chef.log_deprecation "#{self} or set `compile_time true` on the resource if compile_time behavior is required."
end
if compile_time || compile_time.nil?
diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb
index 654f2d72ce..ba0bb08201 100644
--- a/lib/chef/resource/file/verification.rb
+++ b/lib/chef/resource/file/verification.rb
@@ -108,7 +108,7 @@ class Chef
def verify_command(path, opts)
# First implementation interpolated `file`; docs & RFC claim `path`
# is interpolated. Until `file` can be deprecated, interpolate both.
- Chef.log.deprecation(
+ Chef.log_deprecation(
'%{file} is deprecated in verify command and will not be '\
'supported in Chef 13. Please use %{path} instead.'
) if @command.include?('%{file}')
diff --git a/lib/chef/resource_resolver.rb b/lib/chef/resource_resolver.rb
index 14b0ff849d..67cf134c62 100644
--- a/lib/chef/resource_resolver.rb
+++ b/lib/chef/resource_resolver.rb
@@ -56,7 +56,7 @@ class Chef
attr_reader :resource_name
# @api private
def resource
- Chef.log.deprecation("Chef::ResourceResolver.resource deprecated. Use resource_name instead.")
+ Chef.log_deprecation("Chef::ResourceResolver.resource deprecated. Use resource_name instead.")
resource_name
end
# @api private
@@ -174,8 +174,8 @@ class Chef
if handlers.empty?
handlers = resources.select { |handler| overrode_provides?(handler) && handler.provides?(node, resource_name) }
handlers.each do |handler|
- Chef.log.deprecation("#{handler}.provides? returned true when asked if it provides DSL #{resource_name}, but provides #{resource_name.inspect} was never called!")
- Chef.log.deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
+ Chef.log_deprecation("#{handler}.provides? returned true when asked if it provides DSL #{resource_name}, but provides #{resource_name.inspect} was never called!")
+ Chef.log_deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
end
end
handlers
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index dd2da0d7ac..0c8d3d1a48 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -533,22 +533,22 @@ ERROR_MESSAGE
# These need to be settable so deploy can run a resource_collection
# independent of any cookbooks via +recipe_eval+
def resource_collection=(value)
- Chef.log.deprecation("Setting run_context.resource_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
+ Chef.log_deprecation("Setting run_context.resource_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
@resource_collection = value
end
def audits=(value)
- Chef.log.deprecation("Setting run_context.audits will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
+ Chef.log_deprecation("Setting run_context.audits will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
@audits = value
end
def immediate_notification_collection=(value)
- Chef.log.deprecation("Setting run_context.immediate_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
+ Chef.log_deprecation("Setting run_context.immediate_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
@immediate_notification_collection = value
end
def delayed_notification_collection=(value)
- Chef.log.deprecation("Setting run_context.delayed_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
+ Chef.log_deprecation("Setting run_context.delayed_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
@delayed_notification_collection = value
end
end