Class: Terraspace::CLI::Build::Placeholder

Inherits:
Object
  • Object
show all
Includes:
Util::Logging
Defined in:
lib/terraspace/cli/build/placeholder.rb

Instance Method Summary collapse

Methods included from Util::Logging

#logger

Constructor Details

#initialize(options = {}) ⇒ Placeholder

Returns a new instance of Placeholder.



8
9
10
# File 'lib/terraspace/cli/build/placeholder.rb', line 8

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

Instance Method Details

#buildObject

Grab the last module and build that. Assume the backend key has the same prefix Note: Tried building a empty “null” stack but with TFC a null space workspace is created, which is undesired.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/terraspace/cli/build/placeholder.rb', line 15

def build
  return if ENV['TS_SUMMARY_BUILD'] == '0'

  mod = @options[:mod]
  if !mod or %w[placeholder].include?(mod)
    logger.info "Building one of the modules to get backend.tf info"
    mod = find_stack
  end
  Terraspace::Builder.new(@options.merge(mod: mod, init: false)).run # generate and init
  Terraspace::Mod.new(mod, @options) # mod metadata
end

#find_stackObject

Used by: terraspace build placeholder



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/terraspace/cli/build/placeholder.rb', line 28

def find_stack
  stack_paths = Dir.glob("{app,vendor}/stacks/*")
  stack_paths.select! do |path|
    select = Terraspace::Compiler::Select.new(path)
    select.selected?
  end
  mod_path = stack_paths.last
  unless mod_path
    logger.info "No stacks found."
    exit 0
  end
  File.basename(mod_path) # mod name
end