Sha256: b6761420bed3e45997f3cc8ee837c1077c244b0ff97f1c2d6969f46750c6caa2

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require 'aws'
require 'opsworks/deployment'

module OpsWorks
  module CLI
    module Subcommands
      module Update
        # rubocop:disable MethodLength
        # rubocop:disable CyclomaticComplexity
        def self.included(thor)
          thor.class_eval do
            include Helpers::Keychain
            include Helpers::Options

            desc 'update [--stack STACK]', 'Update OpsWorks custom cookbooks'
            option :stack, type: :array
            option :timeout, type: :numeric, default: 300
            def update
              fetch_keychain_credentials unless env_credentials?
              stacks = parse_stacks(options.merge(active: true))
              deployments = stacks.map do |stack|
                say "Updating #{stack.name}..."
                stack.update_custom_cookbooks
              end
              OpsWorks::Deployment.wait(deployments, options[:timeout])
              unless deployments.all?(&:success?)
                failures = []
                deployments.each_with_index do |deployment, i|
                  failures << stacks[i].name unless deployment.success?
                end
                fail "Update failed on #{failures.join(', ')}"
              end
            end
          end
        end
        # rubocop:enable CyclomaticComplexity
        # rubocop:enable MethodLength
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opsworks-cli-0.3.4 lib/opsworks/cli/subcommands/update.rb
opsworks-cli-0.3.3 lib/opsworks/cli/subcommands/update.rb
opsworks-cli-0.3.2 lib/opsworks/cli/subcommands/update.rb
opsworks-cli-0.3.1 lib/opsworks/cli/subcommands/update.rb