summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-01-08 15:29:51 -0800
committerTim Smith <tsmith@chef.io>2017-01-08 15:46:25 -0800
commit3bdc1e2f3d0591eba391eb61a1f11798318ff47e (patch)
tree9112b713a819ee67ecad54dca1372456d9dec210
parent60c7fd2a22cc95a8e52e9c0579ed7d49c531635a (diff)
downloadohai-3bdc1e2f3d0591eba391eb61a1f11798318ff47e.tar.gz
Remove deprecated config logic
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/config.rb89
-rw-r--r--lib/ohai/system.rb1
2 files changed, 2 insertions, 88 deletions
diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb
index f7e1f518..0f90f944 100644
--- a/lib/ohai/config.rb
+++ b/lib/ohai/config.rb
@@ -19,7 +19,6 @@
require "chef-config/config"
require "ohai/exception"
-require "ohai/log"
require "ohai/plugin_config"
module Ohai
@@ -28,98 +27,14 @@ module Ohai
# Reopens ChefConfig::Config to add Ohai configuration settings.
# see: https://github.com/chef/chef/blob/master/lib/chef/config.rb
class Config
- # These methods need to be defined before they are used as config defaults,
- # otherwise they will get method_missing'd to nil.
-
- class << self
- def merge_deprecated_config
- [ :hints_path, :plugin_path ].each do |option|
- if has_key?(option) && send(option) != send("default_#{option}".to_sym)
- Ohai::Log.warn(option_deprecated(option))
- end
- end
-
- ohai.merge!(configuration)
- end
-
- def default_hints_path
- [ ChefConfig::Config.platform_specific_path("/etc/chef/ohai/hints") ]
- end
-
- def default_plugin_path
- [ File.expand_path(File.join(File.dirname(__FILE__), "plugins")) ]
- end
- end
-
- # Copy deprecated configuration options into the ohai config context.
-
- # Keep "old" config defaults around so anyone calling Ohai::Config[:key]
- # won't be broken. Also allows users to append to configuration options
- # (e.g., Ohai::Config[:plugin_path] << some_path) in their config files.
- default :disabled_plugins, []
- default :hints_path, default_hints_path
- default :log_level, :auto
- default :log_location, STDERR
- default :plugin_path, default_plugin_path
-
- # Log deprecation warning when a top-level configuration option is set.
- # TODO: Should we implement a config_attr_reader so that deprecation
- # warnings will be generatd on read?
- [
- :directory,
- :disabled_plugins,
- :log_level,
- :log_location,
- :version,
- ].each do |option|
- # https://docs.chef.io/config_rb_client.html#ohai-settings
- # hints_path and plugin_path are intentionally excluded here; warnings for
- # setting these attributes are generated in merge_deprecated_config since
- # append (<<) operations bypass the config writer.
- config_attr_writer option do |value|
- # log_level and log_location are common configuration options for chef
- # and other chef applications. When configuration files are read there
- # is no distinction between log_level and Ohai::Config[:log_level] and
- # we may emit a false deprecation warning. The deprecation warnings for
- # these settings reflect that possibility.
- # Furthermore, when the top-level config settings are removed we will
- # need to ensure that Ohai.config[:log_level] can be set by writing
- # log_level in a configuration file for consistent behavior with chef.
- deprecation_warning = if [ :log_level, :log_location ].include?(value)
- option_might_be_deprecated(option)
- else
- option_deprecated(option)
- end
- Ohai::Log.warn(deprecation_warning)
- value
- end
- end
config_context :ohai do
default :disabled_plugins, []
- default :hints_path, Ohai::Config.default_hints_path
+ default :hints_path, [ ChefConfig::Config.platform_specific_path("/etc/chef/ohai/hints") ]
default :log_level, :auto
default :log_location, STDERR
default :plugin, Ohai::PluginConfig.new { |h, k| h[k] = Ohai::PluginConfig.new }
- default :plugin_path, Ohai::Config.default_plugin_path
- end
-
- class << self
- def option_deprecated(option)
- <<-EOM.chomp!.tr("\n", " ")
-Ohai::Config[:#{option}] is set. Ohai::Config[:#{option}] is deprecated and will
-be removed in future releases of ohai. Use ohai.#{option} in your configuration
-file to configure :#{option} for ohai.
- EOM
- end
-
- def option_might_be_deprecated(option)
- option_deprecated(option) + <<-EOM.chomp!.tr("\n", " ")
- If your configuration file is used with other applications which configure
-:#{option}, and you have not configured Ohai::Config[:#{option}], you may
-disregard this warning.
- EOM
- end
+ default :plugin_path, [ File.expand_path(File.join(File.dirname(__FILE__), "plugins")), ChefConfig::Config.platform_specific_path("/etc/chef/ohai/plugins") ]
end
end
diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb
index c55383ca..7dd5ac8f 100644
--- a/lib/ohai/system.rb
+++ b/lib/ohai/system.rb
@@ -208,7 +208,6 @@ module Ohai
private
def configure_ohai
- Ohai::Config.merge_deprecated_config
Ohai.config.merge!(@config)
if Ohai.config[:directory] &&