summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-10-22 13:26:20 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-10-24 15:07:13 -0700
commit82329160fa4753a135fa3ef84f2920d1dc24595f (patch)
tree26f0350da5cb05a455279f59ed772ff74076f57d /lib
parent1c1fc315324a5929b1187dd7019f14ce8cf83f5c (diff)
downloadchef-jdmundrawala/11-issue-2225.tar.gz
Merge pull request #2264 from opscode/jdmundrawala/issue-2225jdmundrawala/11-issue-2225
Improve detection missing WhatIf support
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/util/dsc/local_configuration_manager.rb20
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 4d49c8dcff..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(/\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)