Class: Jets::CLI::Release::History

Inherits:
Base
  • Object
show all
Includes:
Util::FormatTime
Defined in:
lib/jets/cli/release/history.rb

Direct Known Subclasses

Info

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods included from Util::FormatTime

#pretty_time, #time_ago_in_words

Methods inherited from Base

#initialize, #paginate, #paging_params, rescue_api_error

Methods included from Util::Logging

#log

Methods included from AwsServices

#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2

Methods included from AwsServices::StackStatus

#output_value, #stack_exists?

Methods included from AwsServices::GlobalMemoist

included, #reset_cache!

Methods included from Api

#api, #api_key

Constructor Details

This class inherits a constructor from Jets::CLI::Base

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jets/cli/release/history.rb', line 9

def run
  resp = Jets::Api::Stack.retrieve(:current)

  name = "#{resp[:name]} #{resp[:location]}"
  resp = Jets::Api::Release.list(@options)

  data = resp[:data]
  if data.empty?
    log.info "No releases found for stack: #{name}"
  else
    log.info "Releases for stack: #{name}"
    show_items(data)
    paginate(resp)
  end
end

#show_items(items) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jets/cli/release/history.rb', line 25

def show_items(items)
  presenter = CliFormat::Presenter.new(@options)
  header = ["Version", "Status", "Released At", "Message"]
  header << "Git Sha" if @options[:sha]
  presenter.header = header
  items.each do |item|
    version = item[:version]
    status = item[:stack_status]
    released_at = item[:created_at]
    message = item[:message] || "Deployed"
    message = message[0..50]

    row = [version, status, pretty_time(released_at), message]
    if @options[:sha]
      sha = item[:git_sha].to_s[0..7] if item[:git_sha]
      row << sha
    end
    presenter.rows << row
  end
  presenter.show
end