Class: Terraspace::Compiler::Perform

Inherits:
Object
  • Object
show all
Includes:
Basename, CommandsConcern
Defined in:
lib/terraspace/compiler/perform.rb,
lib/terraspace/compiler/perform/skip.rb

Defined Under Namespace

Classes: Skip

Instance Method Summary collapse

Methods included from Basename

#basename

Methods included from CommandsConcern

#command_is?

Constructor Details

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

Returns a new instance of Perform.



6
7
8
9
# File 'lib/terraspace/compiler/perform.rb', line 6

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

Instance Method Details

#compileObject



11
12
13
14
15
# File 'lib/terraspace/compiler/perform.rb', line 11

def compile
  compile_config
  compile_module if @mod.resolved
  compile_tfvars
end

#compile_configObject

compile common config files: provider and backend for the root module



18
19
20
21
# File 'lib/terraspace/compiler/perform.rb', line 18

def compile_config
  return unless compile?
  compile_config_terraform
end

#compile_moduleObject



23
24
25
26
27
28
29
30
# File 'lib/terraspace/compiler/perform.rb', line 23

def compile_module
  with_mod_file do |src_path|
    # Skip examples. Dont want to process tfvars <%= output(...) %> which triggers dependency graph
    # Also a speed improvement.
    next if src_path.include?("#{@mod.root}/examples/")
    compile_mod_file(src_path)
  end
end

#compile_tfvars(write: true) ⇒ Object



32
33
34
35
36
# File 'lib/terraspace/compiler/perform.rb', line 32

def compile_tfvars(write: true)
  return unless compile?
  return if command_is?(:seed) # avoid dependencies being built and erroring when backend bucket doesnt exist
  Strategy::Tfvar.new(@mod).run(write: write) # writer within Strategy to control file ordering
end