Class: Chef::Provider::Archive

Inherits:
Chef::Provider show all
Includes:
DSL::IncludeRecipe, Mixin::EnforceOwnershipAndPermissions, Garcon
Defined in:
lib/garcon/chef/provider/archive.rb

Constant Summary

Constants included from Garcon

Garcon::VERSION

Instance Method Summary collapse

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_extractObject



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_zipObject



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_resourceChef::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.

Returns:



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

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).

Returns:



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.

Returns:



111
112
113
# File 'lib/garcon/chef/provider/archive.rb', line 111

def whyrun_supported?
  true
end