Skip to content

Instantly share code, notes, and snippets.

@stevendanna
Last active August 29, 2015 14:04
Show Gist options
  • Save stevendanna/cc34968e4626eb11bf72 to your computer and use it in GitHub Desktop.
Save stevendanna/cc34968e4626eb11bf72 to your computer and use it in GitHub Desktop.
verify monkey-patch
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