Class: Terraspace::Builder
Defined Under Namespace
Classes: Allow
Instance Attribute Summary collapse
Instance Method Summary
collapse
#run_hooks
#cache_dirs, #dirs, #local_paths, #mod_names, #select_stack?, #stack_names, #with_each_mod
#command_is?, #requires_backend?, #requires_backend_commands
Methods inherited from CLI::Base
#initialize
#pretty_path, #pretty_time
Methods included from Util::Sure
#sure?
#logger
Instance Attribute Details
#graph ⇒ Object
Returns the value of attribute graph.
7
8
9
|
# File 'lib/terraspace/builder.rb', line 7
def graph
@graph
end
|
Instance Method Details
#auto_create_backend ⇒ Object
Auto create after build_unresolved since will need to run state pull for dependencies
#build_batches ⇒ Object
Builds dependency graph and returns the batches to run
#build_dir(type_dir) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/terraspace/builder.rb', line 60
def build_dir(type_dir)
with_each_mod(type_dir) do |mod|
mod.resolved = @resolved
is_root_module = mod.cache_dir == @mod.cache_dir
next if is_root_module Compiler::Builder.new(mod).build
end
end
|
#build_root_module ⇒ Object
55
56
57
58
|
# File 'lib/terraspace/builder.rb', line 55
def build_root_module
@mod.resolved = @resolved
Compiler::Builder.new(@mod).build
end
|
#build_unresolved ⇒ Object
49
50
51
52
53
|
# File 'lib/terraspace/builder.rb', line 49
def build_unresolved
build_dir("modules")
build_dir("stacks")
build_root_module
end
|
#check_allow! ⇒ Object
31
32
33
|
# File 'lib/terraspace/builder.rb', line 31
def check_allow!
Allow.new(@mod).check!
end
|
#clean ⇒ Object
76
77
78
|
# File 'lib/terraspace/builder.rb', line 76
def clean
Compiler::Cleaner.new(@mod, @options).clean if clean?
end
|
#clean? ⇒ Boolean
80
81
82
83
84
85
86
87
|
# File 'lib/terraspace/builder.rb', line 80
def clean?
if @options[:clean].nil?
clean_cache = Terraspace.config.build.clean_cache
clean_cache.nil? ? true : clean_cache
else
@options[:clean]
end
end
|
#placeholder_stack_message ⇒ Object
89
90
91
92
93
|
# File 'lib/terraspace/builder.rb', line 89
def placeholder_stack_message
return if @options[:quiet]
return unless @options[:mod] == "placeholder"
logger.info "Building one stack to build all stacks"
end
|
#run ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/terraspace/builder.rb', line 9
def run
return if @options[:build] == false
Terraspace::CLI::CheckSetup.check!
@mod.root_module = true
clean
build_dir = Util.pretty_path(@mod.cache_dir)
placeholder_stack_message
logger.info "Building #{build_dir}" unless @options[:quiet]
batches = nil
FileUtils.mkdir_p(@mod.cache_dir) run_hooks("terraspace.rb", "build") do
check_allow!
build_unresolved
auto_create_backend
batches = build_batches
build_all
logger.info "Built in #{build_dir}" unless @options[:quiet] end
batches
end
|