Class: R10K::Action::Environment::Deploy

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/r10k/action/environment.rb

Instance Method Summary collapse

Methods included from Logging

formatter, included, level, level=, #logger, outputter

Constructor Details

#initialize(app, root) ⇒ Deploy

Returns a new instance of Deploy.

Parameters:

  • app (Object)

    The next application in the middlware stack

  • mod (R10K::Module)

    The module to deploy



18
19
20
# File 'lib/r10k/action/environment.rb', line 18

def initialize(app, root)
  @app, @root = app, root
end

Instance Method Details

#call(env) ⇒ Object

Parameters:

  • env (Hash)

Options Hash (env):

  • :update_cache (true, false)
  • :recurse (true, false)
  • :trace (true, false)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/r10k/action/environment.rb', line 27

def call(env)
  @env = env

  logger.info "Deploying environment #{@root.name}"
  FileUtils.mkdir_p @root.full_path
  @root.sync! :update_cache => @env[:update_cache]

  if @env[:recurse]
    # Build a new middleware chain and run it
    stack = Middleware::Builder.new
    @root.modules.each { |mod| stack.use R10K::Action::Module::Deploy, mod }
    stack.call(@env)
  end

  @app.call(@env)
rescue R10K::ExecutionFailure => e
  logger.error "Could not synchronize #{@root.full_path}: #{e}".red
  $stderr.puts e.backtrace.join("\n").red if @env[:trace]
  @app.call(@env)
end