diff options
author | danielsdeleo <dan@opscode.com> | 2012-12-10 16:05:54 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-01-03 16:26:26 -0800 |
commit | 8be5dcbfa21315ba97204e498d02e42cf2ccde2e (patch) | |
tree | 61672ece37ab41f8299b4d07698e469c14daea91 /lib/chef/provider/template.rb | |
parent | b5f34643733d23bab6495c9952e068515343c766 (diff) | |
download | chef-8be5dcbfa21315ba97204e498d02e42cf2ccde2e.tar.gz |
[CHEF-3557] remove load_current_resource_attrs
Functionality was a duplicate of ScanAccessControl with some slightly
different behavior. Correct behavior is now implemented in
ScanAccessControl.
Diffstat (limited to 'lib/chef/provider/template.rb')
-rw-r--r-- | lib/chef/provider/template.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb index 4dcf23cb4e..fbd5c600b9 100644 --- a/lib/chef/provider/template.rb +++ b/lib/chef/provider/template.rb @@ -51,14 +51,17 @@ class Chef def action_create render_with_context(template_location) do |rendered_template| rendered(rendered_template) - update = ::File.exist?(@new_resource.path) - if update && content_matches? + if file_already_exists? && content_matches? Chef::Log.debug("#{@new_resource} content has not changed.") set_all_access_controls + update_new_file_state(@new_resource.path) else - description = [] - action_message = update ? "update #{@current_resource} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(@new_resource.checksum)}" : + description = [] + action_message = if file_already_exists? + "update #{@current_resource} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(@new_resource.checksum)}" + else "create #{@new_resource}" + end description << action_message description << diff_current(rendered_template.path) converge_by(description) do @@ -66,17 +69,10 @@ class Chef FileUtils.mv(rendered_template.path, @new_resource.path) Chef::Log.info("#{@new_resource} updated content") access_controls.set_all! - stat = ::File.stat(@new_resource.path) - - # template depends on the checksum not changing, and updates it - # itself later in the code, so we cannot set it here, as we do with - # all other < File child provider classes - @new_resource.owner(stat.uid) - @new_resource.mode(stat.mode & 07777) - @new_resource.group(stat.gid) + update_new_file_state(@new_resource.path) end end - end + end end def template_finder @@ -107,6 +103,10 @@ class Chef private + def file_already_exists? + ::File.exist?(@new_resource.path) + end + def render_with_context(template_location, &block) context = {} context.merge!(@new_resource.variables) |