Module: R10K::CLI::Environment::Deploy

Defined in:
lib/r10k/cli/environment/deploy.rb

Class Method Summary collapse

Class Method Details

.commandObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/r10k/cli/environment/deploy.rb', line 10

def self.command
  @cmd ||= Cri::Command.define do
    name  'deploy'
    usage 'deploy <environment> <...>'
    summary 'Deploy an environment'

    flag :r, :recurse, 'Recursively update submodules'
    flag :u, :update, "Enable or disable cache updating"

    run do |opts, args, cmd|
      deployment = R10K::Deployment.instance
      env_list   = deployment.environments

      if not args.empty?
        environments = env_list.select {|env| args.include? env.name }
      else
        environments = env_list
      end

      stack = Middleware::Builder.new do
        environments.each do |env|
          use R10K::Action::Environment::Deploy, env
        end
      end

      # Prepare middleware environment
      stack_env = {
        :update_cache => opts[:update],
        :recurse      => opts[:recurse],
        :trace        => opts[:trace],
      }

      stack.call(stack_env)
    end
  end
end