Sha256: 58a017bd5b0d845d2b76526d9aaf006832d82a26ef37735803041c0f173ef4cf

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 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
            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)
              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.2.4 lib/opsworks/cli/subcommands/update.rb
opsworks-cli-0.2.3 lib/opsworks/cli/subcommands/update.rb
opsworks-cli-0.2.2 lib/opsworks/cli/subcommands/update.rb
opsworks-cli-0.2.1 lib/opsworks/cli/subcommands/update.rb