diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-04-30 12:16:39 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-05-01 11:09:49 -0700 |
commit | 92824ed4962d4dfa713a31e2395210781c167b86 (patch) | |
tree | d59b34f4819109ade8d523cf4b69cf105a205d17 /lib/chef/resource/file.rb | |
parent | a5f5748653d0ffd90292be2aabfea7783be12f2b (diff) | |
download | chef-92824ed4962d4dfa713a31e2395210781c167b86.tar.gz |
create Chef::Resource#state_for_resource_reporter
Use this to override the state reported by the resource reporter
while avoiding the collision over Chef::Resource#state being used
by some LWRPs.
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..d1e34f5728 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 |