Class: Dri::Commands::Fetch::Pipelines

Inherits:
Dri::Command show all
Includes:
Utils::Constants, Utils::Table
Defined in:
lib/dri/commands/fetch/pipelines.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

NUM_OF_TESTS_LIVE_ENV =
1000
NOT_FOUND =
"Not found"

Constants included from Utils::Constants

Utils::Constants::PIPELINE_ENVIRONMENTS

Instance Method Summary collapse

Methods included from Utils::Table

#print_table

Methods inherited from Dri::Command

#add_color, #api_client, #bold, #command, #config, #cursor, #editor, #emoji, #handover_report_path, #logger, #ops_token, #pastel, #profile, #prompt, #spinner, #timezone, #token, #username, #verify_config_exists

Constructor Details

#initialize(options) ⇒ Pipelines

Returns a new instance of Pipelines.



19
20
21
# File 'lib/dri/commands/fetch/pipelines.rb', line 19

def initialize(options)
  @options = options
end

Instance Method Details

#executeObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dri/commands/fetch/pipelines.rb', line 23

def execute(*)
  verify_config_exists
  logger.info "Fetching pipelines' status, this might take a while..."
  logger.warn "This command needs a large window to correctly print the table"
  pipelines = []
  table_labels = define_table_labels

  spinner.run do
    PIPELINE_ENVIRONMENTS.each do |environment, details|
      logger.info "Fetching last executed #{environment} pipeline"
      pipelines << fetch_pipeline(pipeline_name: environment.to_s, details: details)
      logger.info "Fetching complete for #{environment}"
    end
  end

  print_table(
    table_labels,
    pipelines,
    alignments: [:center, :center, :center, :center, :center],
    padding: [1, 1, 1, 1]
  )
  pipelines # Returning the array mainly for spec
end