From d08cbdaad788da3b9b1658717353f939361b3add Mon Sep 17 00:00:00 2001 From: Steven Murawski Date: Tue, 4 Apr 2017 15:29:44 -0500 Subject: removing the use of Chef::Exception::DeprecatedExitCode Signed-off-by: Steven Murawski --- lib/chef/application/exit_code.rb | 10 +--------- lib/chef/application/windows_service.rb | 6 +++--- lib/chef/config_fetcher.rb | 8 ++++---- lib/chef/exceptions.rb | 6 ------ spec/unit/application/exit_code_spec.rb | 6 +----- spec/unit/config_fetcher_spec.rb | 4 ++-- 6 files changed, 11 insertions(+), 29 deletions(-) diff --git a/lib/chef/application/exit_code.rb b/lib/chef/application/exit_code.rb index 246c95380b..917aa16e62 100644 --- a/lib/chef/application/exit_code.rb +++ b/lib/chef/application/exit_code.rb @@ -72,8 +72,6 @@ class Chef VALID_RFC_062_EXIT_CODES[:SIGINT_RECEIVED] elsif sigterm_received?(exception) VALID_RFC_062_EXIT_CODES[:SIGTERM_RECEIVED] - elsif legacy_exit_code?(exception) - VALID_RFC_062_EXIT_CODES[:GENERIC_FAILURE] elsif reboot_scheduled?(exception) VALID_RFC_062_EXIT_CODES[:REBOOT_SCHEDULED] elsif reboot_needed?(exception) @@ -89,12 +87,6 @@ class Chef end end - def legacy_exit_code?(exception) - resolve_exception_array(exception).any? do |e| - e.is_a? Chef::Exceptions::DeprecatedExitCode - end - end - def reboot_scheduled?(exception) resolve_exception_array(exception).any? do |e| e.is_a? Chef::Exceptions::Reboot @@ -162,7 +154,7 @@ class Chef "Chef attempted to exit with a non-standard exit code of #{exit_code}." \ " Chef RFC 062 (https://github.com/chef/chef-rfc/blob/master/rfc062-exit-status.md) defines the" \ " exit codes that should be used with Chef. Chef::Application::ExitCode defines valid exit codes" \ - " Non-standard exit codes are redefined as GENERIC_FAILURE." + " Non-standard exit codes are redefined as GENERIC_FAILURE." end end diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb index 7bc68a586d..c30f5d1fe8 100644 --- a/lib/chef/application/windows_service.rb +++ b/lib/chef/application/windows_service.rb @@ -318,11 +318,11 @@ class Chef Chef::Config.merge!(config) rescue SocketError - Chef::Application.fatal!("Error getting config file #{Chef::Config[:config_file]}", Chef::Exceptions::DeprecatedExitCode.new) + Chef::Application.fatal!("Error getting config file #{Chef::Config[:config_file]}") rescue Chef::Exceptions::ConfigurationError => error - Chef::Application.fatal!("Error processing config file #{Chef::Config[:config_file]} with error #{error.message}", Chef::Exceptions::DeprecatedExitCode.new) + Chef::Application.fatal!("Error processing config file #{Chef::Config[:config_file]} with error #{error.message}") rescue Exception => error - Chef::Application.fatal!("Unknown error processing config file #{Chef::Config[:config_file]} with error #{error.message}", Chef::Exceptions::DeprecatedExitCode.new) + Chef::Application.fatal!("Unknown error processing config file #{Chef::Config[:config_file]} with error #{error.message}") end end diff --git a/lib/chef/config_fetcher.rb b/lib/chef/config_fetcher.rb index ee1b64956a..e14428157c 100644 --- a/lib/chef/config_fetcher.rb +++ b/lib/chef/config_fetcher.rb @@ -25,7 +25,7 @@ class Chef begin Chef::JSONCompat.from_json(config_data) rescue Chef::Exceptions::JSON::ParseError => error - Chef::Application.fatal!("Could not parse the provided JSON file (#{config_location}): " + error.message, Chef::Exceptions::DeprecatedExitCode.new) + Chef::Application.fatal!("Could not parse the provided JSON file (#{config_location}): " + error.message) end end @@ -40,15 +40,15 @@ class Chef def fetch_remote_config http.get("") rescue SocketError, SystemCallError, Net::HTTPServerException => error - Chef::Application.fatal!("Cannot fetch config '#{config_location}': '#{error.class}: #{error.message}", Chef::Exceptions::DeprecatedExitCode.new) + Chef::Application.fatal!("Cannot fetch config '#{config_location}': '#{error.class}: #{error.message}") end def read_local_config ::File.read(config_location) rescue Errno::ENOENT - Chef::Application.fatal!("Cannot load configuration from #{config_location}", Chef::Exceptions::DeprecatedExitCode.new) + Chef::Application.fatal!("Cannot load configuration from #{config_location}") rescue Errno::EACCES - Chef::Application.fatal!("Permissions are incorrect on #{config_location}. Please chmod a+r #{config_location}", Chef::Exceptions::DeprecatedExitCode.new) + Chef::Application.fatal!("Permissions are incorrect on #{config_location}. Please chmod a+r #{config_location}") end def config_missing? diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index be46f262a4..a09a3a062c 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -59,12 +59,6 @@ class Chef class UnsupportedAction < RuntimeError; end class MissingLibrary < RuntimeError; end - class DeprecatedExitCode < RuntimeError - def initalize - super "Exiting with a non RFC 062 Exit Code." - end - end - class CannotDetermineNodeName < RuntimeError def initialize super "Unable to determine node name: configure node_name or configure the system's hostname and fqdn" diff --git a/spec/unit/application/exit_code_spec.rb b/spec/unit/application/exit_code_spec.rb index a3e5855f8a..7783cf3ed7 100644 --- a/spec/unit/application/exit_code_spec.rb +++ b/spec/unit/application/exit_code_spec.rb @@ -73,7 +73,7 @@ describe Chef::Application::ExitCode do context "when Chef validates exit codes" do it "does write a warning on non-standard exit codes" do - expect(Chef::Log).to receive(:warn).with( + expect(Chef::Log).to receive(:warn).with( /^Chef attempted to exit with a non-standard exit code of 151/) expect(exit_codes.normalize_exit_code(151)).to eq(1) end @@ -94,10 +94,6 @@ describe Chef::Application::ExitCode do expect(exit_codes.normalize_exit_code(Chef::Exceptions::SigTerm.new("BOOM"))).to eq(3) end - it "returns GENERIC_FAILURE when a deprecated exit code error is received" do - expect(exit_codes.normalize_exit_code(Chef::Exceptions::DeprecatedExitCode.new("BOOM"))).to eq(1) - end - it "returns GENERIC_FAILURE when an exception is specified" do expect(exit_codes.normalize_exit_code(Exception.new("BOOM"))).to eq(1) end diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb index 6847ee5fd3..a674d4de33 100644 --- a/spec/unit/config_fetcher_spec.rb +++ b/spec/unit/config_fetcher_spec.rb @@ -58,7 +58,7 @@ describe Chef::ConfigFetcher do and_return(invalid_json) expect(Chef::Application).to receive(:fatal!). - with(invalid_json_error_regex, Chef::Exceptions::DeprecatedExitCode.new) + with(invalid_json_error_regex) fetcher.fetch_json end end @@ -104,7 +104,7 @@ describe Chef::ConfigFetcher do with("").and_return(invalid_json) expect(Chef::Application).to receive(:fatal!). - with(invalid_json_error_regex, Chef::Exceptions::DeprecatedExitCode.new) + with(invalid_json_error_regex) fetcher.fetch_json end end -- cgit v1.2.1