lib/kitchen/lifecycle_hooks.rb
def run(instance, phase, state_file, hook_timing)
      # Yes this has to be a symbol because of how data munger works.
      hook_key = :"#{hook_timing}_#{phase}"
      # No hooks? We're outta here.
      hook_data = Array(config[hook_key])
      return if hook_data.empty?
      hook_data.each do |hook|
        # Coerce the common case of a bare string to be a local command. This
        # is to match the behavior of the old `pre_create_command` semi-hook.
        hook = { local: hook } if hook.is_a?(String)
        if hook.include?(:local)
          # Local command execution on the workstation.
          run_local_hook(instance, state_file, hook)
        elsif hook.include?(:remote)
          # Remote command execution on the test instance.
          run_remote_hook(instance, state_file, hook)
        else
          raise UserError, "Unknown lifecycle hook target #{hook.inspect}"
        end
      end
    end
# Execute a specific lifecycle hook.
#
# @param instance [Instance] The instance object to run against.
# @param phase [String] Lifecycle phase which is being executed.
# @param state_file [StateFile] Instance state file object.
# @param hook_timing [Symbol] `:pre` or `:post` to indicate which hook to run.
# @return [void]
Execute a specific lifecycle hook.
Execute a specific lifecycle hook .
def run(instance, phase, state_file, hook_timing)
      hook_key = :"#{hook_timing}_#{phase}"
      hook_data = Array(config[hook_key])
      return if hook_data.empty?
      hook_data.each do |hook|
        hook = { local: hook } if hook.is_a?(String)
        if hook.include?(:local)
          run_local_hook(instance, state_file, hook)
        elsif hook.include?(:remote)
          run_remote_hook(instance, state_file, hook)
        else
          raise UserError, "Unknown lifecycle hook target #{hook.inspect}"
        end
      end
    end
def run ( instance , phase , state_file , hook_timing ) hook_key = :" #{ hook_timing } _ #{ phase } " hook_data = Array ( config [ hook_key ] ) return if hook_data . empty? hook_data . each do | hook | hook = { local : hook } if hook . is_a? ( String ) if hook . include? ( :local ) run_local_hook ( instance , state_file , hook ) elsif hook . include? ( :remote ) run_remote_hook ( instance , state_file , hook ) else raise UserError , "Unknown lifecycle hook target #{hook.inspect}" end end end
Execute a specific lifecycle hook.
Execute a specific lifecycle hook .
# Yes this has to be a symbol because of how data munger works. # No hooks? We're outta here. # Coerce the common case of a bare string to be a local command. This # is to match the behavior of the old `pre_create_command` semi-hook. # Local command execution on the workstation. # Remote command execution on the test instance.
None
void
instance
The instance object to run against.
The instance object to run against .
phase
Lifecycle phase which is being executed.
Lifecycle phase which is being executed .
state_file
Instance state file object.
Instance state file object .
hook_timing
`:pre` or `:post` to indicate which hook to run.
` : pre ` or ` : post ` to indicate which hook to run .