Sha256: b8fa62ed9726e4080aef79077cf182a2f7f856a1800cc9e91ff0690550fa2cee

Contents?: true

Size: 1.38 KB

Versions: 1

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 [--stack STACK] APP',
                 '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.sort! { |x, y| y.last <=> x.last }
              table.compact!
              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

1 entries across 1 versions & 1 rubygems

Version Path
opsworks-cli-0.2.0 lib/opsworks/cli/subcommands/status.rb