Class: Terraspace::Terraform::Tfc::Runs::Base

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
Api::Client, Util::Logging, Util::Sure
Defined in:
lib/terraspace/terraform/tfc/runs/base.rb

Direct Known Subclasses

Lister, Pruner

Instance Method Summary collapse

Methods included from Api::Client

#api, #backend, #build, #remote, #workspace_name

Methods included from Util::Sure

#sure?

Methods included from Util::Logging

#logger

Constructor Details

#initialize(mod, options = {}) ⇒ Base

Api::Client requires @mod to be set



9
10
11
# File 'lib/terraspace/terraform/tfc/runs/base.rb', line 9

def initialize(mod, options={})
  @mod, @options = mod, options
end

Instance Method Details

#build_projectObject



24
25
26
27
28
29
30
31
# File 'lib/terraspace/terraform/tfc/runs/base.rb', line 24

def build_project
  Terraspace::Builder.new(@options).run

  unless remote && remote['organization']
    logger.info "ERROR: There was no organization found. Are you sure you configured backend.tf with it?".color(:red)
    exit 1
  end
end

#runsObject



13
14
15
16
17
18
19
20
21
# File 'lib/terraspace/terraform/tfc/runs/base.rb', line 13

def runs
  runs = api.runs.list
  runs.select! do |item|
    @options[:status].nil? ||
    @options[:status].include?("all") ||
    @options[:status].include?(item['attributes']['status'])
  end
  runs
end