Class: Chef::Provider::Archive
- Inherits:
-
Chef::Provider
- Object
- Chef::Provider
- Chef::Provider::Archive
- Includes:
- DSL::IncludeRecipe, Mixin::EnforceOwnershipAndPermissions, Garcon
- Defined in:
- lib/garcon/chef/provider/archive.rb
Constant Summary
Constants included from Garcon
Instance Method Summary collapse
- #action_extract ⇒ Object
- #action_zip ⇒ Object
-
#initialize(new_resource, run_context) ⇒ Archive
constructor
A new instance of Archive.
-
#load_current_resource ⇒ Chef::Provider
private
Load and return the current resource.
-
#manage_symlink_access? ⇒ Boolean
Implementation components should follow symlinks when managing access control (e.g., use chmod instead of lchmod even if the path we’re managing is a symlink).
-
#whyrun_supported? ⇒ TrueClass, FalseClass
private
Boolean indicating if WhyRun is supported by this provider.
Methods included from Garcon
auto_terminate_all_executors?, auto_terminate_global_executors?, coercer, coercer=, config, configuration, crypto, crypto=, disable_auto_termination_of_all_executors!, disable_auto_termination_of_global_executors!, global_fast_executor, global_io_executor, global_timer_set, included, #inspect, kill_global_executors, monotonic_time, new_fast_executor, new_io_executor, physical_processor_count, processor_count, secret, secret=, shutdown_global_executors, #terminal_dimensions, timer, #to_s, wait_for_global_executors_termination, warn
Constructor Details
#initialize(new_resource, run_context) ⇒ Archive
Returns a new instance of Archive.
97 98 99 100 |
# File 'lib/garcon/chef/provider/archive.rb', line 97 def initialize(new_resource, run_context) super __zip__ unless defined?(Zip) end |
Instance Method Details
#action_extract ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/garcon/chef/provider/archive.rb', line 125 def action_extract converge_by "Extracting #{r.source} to #{r.path}" do extract do_acl_changes ::File.unlink(cached_file) if r.remove_after end r.updated_by_last_action(true) end |
#action_zip ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/garcon/chef/provider/archive.rb', line 134 def action_zip if ::File.exists?(r.path) && !r.overwrite Chef::Log.info "#{r.path} already exists - nothing to do" else ::File.unlink(r.path) if ::File.exists?(r.path) if ::File.directory?(r.source) converge_by "Zip #{r.source}" do z = Zip::File.new(r.path, true) Find.find(r.source) do |f| next if f == r.source zip_fname = f.sub(r.source, '') z.add(zip_fname, f) end z.close do_acl_changes r.updated_by_last_action(true) end else Chef::Log.warn 'A valid directory must be specified for ziping.' end end end |
#load_current_resource ⇒ Chef::Provider
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Load and return the current resource.
120 121 122 123 |
# File 'lib/garcon/chef/provider/archive.rb', line 120 def load_current_resource @current_resource ||= Chef::Resource::Archive.new(r.name) @current_resource end |
#manage_symlink_access? ⇒ Boolean
Implementation components should follow symlinks when managing access control (e.g., use chmod instead of lchmod even if the path we’re managing is a symlink).
161 162 163 |
# File 'lib/garcon/chef/provider/archive.rb', line 161 def manage_symlink_access? false end |
#whyrun_supported? ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Boolean indicating if WhyRun is supported by this provider.
111 112 113 |
# File 'lib/garcon/chef/provider/archive.rb', line 111 def whyrun_supported? true end |