diff options
Diffstat (limited to 'lib/chef/resource/file.rb')
-rw-r--r-- | lib/chef/resource/file.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb index 53a6a160af..b36fcc2135 100644 --- a/lib/chef/resource/file.rb +++ b/lib/chef/resource/file.rb @@ -38,6 +38,15 @@ class Chef attr_writer :checksum + # + # The checksum of the rendered file. This has to be saved on the + # new_resource for the 'after' state for reporting but we cannot + # mutate the new_resource.checksum which would change the + # user intent in the new_resource if the resource is reused. + # + # @returns [String] Checksum of the file we actually rendered + attr_accessor :final_checksum + provides :file def initialize(name, run_context=nil) @@ -129,6 +138,15 @@ class Chef @verifications end end + + def state_for_resource_reporter + state_attrs = super() + # fix up checksum state with final_checksum saved by the provider + if checksum.nil? && final_checksum + state_attrs[:checksum] = final_checksum + end + state_attrs + end end end end |