Sha256: 5e33edc8d69d0ea2237e98fd1eadbd38e2b03dc379ee5b635dbbde1594a17e21

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

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

            desc 'status APP [--stack STACK]',
                 'Display the most recent deployment of an app'
            option :stack, type: :array
            def status(name)
              fetch_keychain_credentials unless env_credentials?

              table = parse_stacks(options).map do |stack|
                next unless (app = stack.find_app_by_name(name))
                if (deployment = app.last_deployment)
                  deployed_at = formatted_time(deployment.created_at)
                else
                  deployed_at = '-'
                end
                [stack.name, name, "(#{app.revision})", deployed_at]
              end
              # Sort output in descending date order
              table.compact!
              table.sort! { |x, y| y.last <=> x.last }
              print_table table
            end

            private

            def formatted_time(timestamp)
              timestamp.strftime('%Y-%m-%d %H:%M:%S %Z')
            end
          end
        end
        # rubocop:enable CyclomaticComplexity
        # rubocop:enable MethodLength
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opsworks-cli-0.2.4 lib/opsworks/cli/subcommands/status.rb
opsworks-cli-0.2.3 lib/opsworks/cli/subcommands/status.rb
opsworks-cli-0.2.2 lib/opsworks/cli/subcommands/status.rb