Last active
August 29, 2015 14:04
-
-
Save stevendanna/cc34968e4626eb11bf72 to your computer and use it in GitHub Desktop.
verify monkey-patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chef::Resource::File | |
def verify(&block) | |
if block_given? | |
@verify_block=block | |
else | |
@verify_block | |
end | |
end | |
end | |
class Chef::Provider::File | |
alias_method :old_dcc, :do_contents_changes | |
def do_contents_changes | |
do_verify if !@new_resource.verify.nil? | |
old_dcc | |
end | |
def do_verify | |
Chef::Log.debug "Validating rendered file" | |
unless @new_resource.verify.call(tempfile.path) | |
raise Chef::Exceptions::ValidationFailed, "Could not validate rendered file" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment