diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-10-20 14:08:48 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-10-22 12:23:46 -0700 |
commit | a2128b7aaa5ad494ea17559cfe3796f2cb2e5e6c (patch) | |
tree | 56074ab813e9ccdb1af25148d6b10971053f862e /lib/chef/util/dsc | |
parent | 289aefe1049185257f0b7f0024872aa79d79d0b2 (diff) | |
download | chef-a2128b7aaa5ad494ea17559cfe3796f2cb2e5e6c.tar.gz |
Refactored local_configuration_manager to use function to test for what-if support
Diffstat (limited to 'lib/chef/util/dsc')
-rw-r--r-- | lib/chef/util/dsc/local_configuration_manager.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb index b55d0c364a..f498a2bfea 100644 --- a/lib/chef/util/dsc/local_configuration_manager.rb +++ b/lib/chef/util/dsc/local_configuration_manager.rb @@ -79,14 +79,18 @@ EOH end def log_what_if_exception(what_if_exception_output) - if what_if_exception_output.gsub(/[\r\n]+/, '').gsub(/\s+/, ' ') =~ /A parameter cannot be found that matches parameter name 'Whatif'/i - # LCM returns an error if any of the resources do not support the opptional What-If - Chef::Log::warn("Received error while testing configuration due to resource not supporting 'WhatIf'") - elsif dsc_module_import_failure?(what_if_exception_output) - Chef::Log::warn("Received error while testing configuration due to a module for an imported resource possibly not being fully installed:\n#{what_if_exception_output.gsub(/\s+/, ' ')}") - else - Chef::Log::warn("Received error while testing configuration:\n#{what_if_exception_output.gsub(/\s+/, ' ')}") - end + if whatif_not_supported?(what_if_exception_output) + # LCM returns an error if any of the resources do not support the opptional What-If + Chef::Log::warn("Received error while testing configuration due to resource not supporting 'WhatIf'") + elsif dsc_module_import_failure?(what_if_exception_output) + Chef::Log::warn("Received error while testing configuration due to a module for an imported resource possibly not being fully installed:\n#{what_if_exception_output.gsub(/\s+/, ' ')}") + else + Chef::Log::warn("Received error while testing configuration:\n#{what_if_exception_output.gsub(/\s+/, ' ')}") + end + end + + def whatif_not_supported?(what_if_exception_output) + !! (what_if_exception_output.gsub(/[\r\n]+/, '').gsub(/\s+/, ' ') =~ /A parameter cannot be found that matches parameter name 'Whatif'/i) end def dsc_module_import_failure?(what_if_output) |