Module: OpsWorks::CLI::Subcommands::Deploy

Included in:
Agent
Defined in:
lib/opsworks/cli/subcommands/deploy.rb

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object

rubocop:disable MethodLength rubocop:disable CyclomaticComplexity



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/opsworks/cli/subcommands/deploy.rb', line 9

def self.included(thor)
  thor.class_eval do
    desc 'deploy APP [--stack STACK]', 'Deploy an OpsWorks app'
    option :stack, type: :array
    def deploy(name)
      fetch_keychain_credentials unless env_credentials?
      stacks = parse_stacks(options.merge(active: true))
      deployments = stacks.map do |stack|
        next unless (app = stack.find_app_by_name(name))
        say "Deploying to #{stack.name}..."
        stack.deploy_app(app)
      end
      deployments.compact!
      OpsWorks::Deployment.wait(deployments)
      unless deployments.all?(&:success?)
        failures = []
        deployments.each_with_index do |deployment, i|
          failures << stacks[i].name unless deployment.success?
        end
        fail "Deploy failed on #{failures.join(', ')}"
      end
    end
  end
end