diff options
Diffstat (limited to 'lib/chef/application.rb')
-rw-r--r-- | lib/chef/application.rb | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb index a2718e7556..297e46ef3c 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -17,6 +17,7 @@ # limitations under the License. require 'pp' +require 'uri' require 'socket' require 'chef/config' require 'chef/config_fetcher' @@ -48,6 +49,7 @@ class Chef configure_logging configure_proxy_environment_variables configure_encoding + emit_warnings end # Get this party started @@ -102,6 +104,12 @@ class Chef Chef::Config.merge!(config) end + def set_specific_recipes + Chef::Config[:specific_recipes] = + cli_arguments.map { |file| File.expand_path(file) } if + cli_arguments.respond_to?(:map) + end + # Initialize and configure the logger. # === Loggers and Formatters # In Chef 10.x and previous, the Logger was the primary/only way that Chef @@ -198,16 +206,18 @@ class Chef # Initializes Chef::Client instance and runs it def run_chef_client(specific_recipes = []) + unless specific_recipes.respond_to?(:size) + raise ArgumentError, 'received non-Array like specific_recipes argument' + end + Chef::LocalMode.with_server_connectivity do override_runlist = config[:override_runlist] - if specific_recipes.size > 0 - override_runlist ||= [] - end + override_runlist ||= [] if specific_recipes.size > 0 @chef_client = Chef::Client.new( @chef_client_json, - :override_runlist => config[:override_runlist], - :specific_recipes => specific_recipes, - :runlist => config[:runlist] + override_runlist: override_runlist, + specific_recipes: specific_recipes, + runlist: config[:runlist] ) @chef_client_json = nil @@ -226,7 +236,7 @@ class Chef private def can_fork? # win32-process gem exposes some form of :fork for Process - # class. So we are seperately ensuring that the platform we're + # class. So we are separately ensuring that the platform we're # running on is not windows before forking. Chef::Config[:client_fork] && Process.respond_to?(:fork) && !Chef::Platform.windows? end @@ -237,7 +247,7 @@ class Chef # Override the TERM signal. trap('TERM') do Chef::Log.debug("SIGTERM received during converge," + - " finishing converge to exit normally (send SIGINT to terminate immediately)") + " finishing converge to exit normally (send SIGINT to terminate immediately)") end @chef_client.run @@ -251,7 +261,7 @@ class Chef # TERM singal is received (exit gracefully) trap('TERM') do Chef::Log.debug("SIGTERM received during converge," + - " finishing converge to exit normally (send SIGINT to terminate immediately)") + " finishing converge to exit normally (send SIGINT to terminate immediately)") end client_solo = Chef::Config[:solo] ? "chef-solo" : "chef-client" @@ -297,7 +307,7 @@ class Chef def configure_http_proxy if http_proxy = Chef::Config[:http_proxy] http_proxy_string = configure_proxy("http", http_proxy, - Chef::Config[:http_proxy_user], Chef::Config[:http_proxy_pass]) + Chef::Config[:http_proxy_user], Chef::Config[:http_proxy_pass]) env['http_proxy'] = http_proxy_string unless env['http_proxy'] env['HTTP_PROXY'] = http_proxy_string unless env['HTTP_PROXY'] end @@ -307,7 +317,7 @@ class Chef def configure_https_proxy if https_proxy = Chef::Config[:https_proxy] https_proxy_string = configure_proxy("https", https_proxy, - Chef::Config[:https_proxy_user], Chef::Config[:https_proxy_pass]) + Chef::Config[:https_proxy_user], Chef::Config[:https_proxy_pass]) env['https_proxy'] = https_proxy_string unless env['https_proxy'] env['HTTPS_PROXY'] = https_proxy_string unless env['HTTPS_PROXY'] end @@ -317,7 +327,7 @@ class Chef def configure_ftp_proxy if ftp_proxy = Chef::Config[:ftp_proxy] ftp_proxy_string = configure_proxy("ftp", ftp_proxy, - Chef::Config[:ftp_proxy_user], Chef::Config[:ftp_proxy_pass]) + Chef::Config[:ftp_proxy_user], Chef::Config[:ftp_proxy_pass]) env['ftp_proxy'] = ftp_proxy_string unless env['ftp_proxy'] env['FTP_PROXY'] = ftp_proxy_string unless env['FTP_PROXY'] end @@ -371,6 +381,12 @@ class Chef ENV end + def emit_warnings + if Chef::Config[:chef_gem_compile_time] + Chef::Log.deprecation "setting chef_gem_compile_time to true is deprecated" + end + end + class << self def debug_stacktrace(e) message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}" |