terraspace 0.3.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/aws/bin/build.sh +2 -0
- data/.cody/azurerm/bin/build.sh +2 -0
- data/.cody/google/bin/build.sh +2 -0
- data/CHANGELOG.md +39 -0
- data/README.md +1 -1
- data/lib/templates/base/project/README.md +1 -1
- data/lib/terraspace.rb +1 -0
- data/lib/terraspace/all/preview.rb +1 -1
- data/lib/terraspace/all/runner.rb +1 -0
- data/lib/terraspace/all/summary.rb +29 -2
- data/lib/terraspace/app.rb +9 -5
- data/lib/terraspace/builder.rb +10 -6
- data/lib/terraspace/cli.rb +33 -39
- data/lib/terraspace/cli/all.rb +15 -9
- data/lib/terraspace/cli/bundle.rb +2 -1
- data/lib/terraspace/cli/clean.rb +18 -6
- data/lib/terraspace/cli/clean/all.rb +18 -0
- data/lib/terraspace/cli/clean/base.rb +15 -0
- data/lib/terraspace/cli/clean/cache.rb +25 -0
- data/lib/terraspace/cli/{logs/tasks.rb → clean/logs.rb} +16 -5
- data/lib/terraspace/cli/cloud.rb +3 -9
- data/lib/terraspace/cli/cloud/runs.rb +0 -2
- data/lib/terraspace/cli/help/all/down.md +32 -0
- data/lib/terraspace/cli/help/all/graph.md +21 -0
- data/lib/terraspace/cli/help/all/init.md +33 -0
- data/lib/terraspace/cli/help/all/output.md +22 -0
- data/lib/terraspace/cli/help/all/plan.md +25 -0
- data/lib/terraspace/cli/help/all/providers.md +21 -0
- data/lib/terraspace/cli/help/all/refresh.md +17 -0
- data/lib/terraspace/cli/help/all/show.md +21 -0
- data/lib/terraspace/cli/help/all/up.md +27 -0
- data/lib/terraspace/cli/help/all/validate.md +21 -0
- data/lib/terraspace/cli/help/build.md +6 -0
- data/lib/terraspace/cli/help/bundle.md +9 -5
- data/lib/terraspace/cli/help/check_setup.md +9 -0
- data/lib/terraspace/cli/help/clean/all.md +10 -0
- data/lib/terraspace/cli/help/clean/cache.md +12 -0
- data/lib/terraspace/cli/help/clean/logs.md +17 -0
- data/lib/terraspace/cli/help/cloud/destroy.md +16 -0
- data/lib/terraspace/cli/help/cloud/list.md +7 -0
- data/lib/terraspace/cli/help/cloud/runs/list.md +3 -3
- data/lib/terraspace/cli/help/cloud/runs/prune.md +1 -1
- data/lib/terraspace/cli/help/cloud/sync.md +26 -2
- data/lib/terraspace/cli/help/console.md +8 -0
- data/lib/terraspace/cli/help/down.md +26 -0
- data/lib/terraspace/cli/help/info.md +43 -0
- data/lib/terraspace/cli/help/init.md +37 -0
- data/lib/terraspace/cli/help/list.md +20 -0
- data/lib/terraspace/cli/help/logs.md +48 -0
- data/lib/terraspace/cli/help/logs/remove.md +5 -0
- data/lib/terraspace/cli/help/logs/truncate.md +5 -0
- data/lib/terraspace/cli/help/new/bootstrap_test.md +8 -0
- data/lib/terraspace/cli/help/new/example.md +8 -0
- data/lib/terraspace/cli/help/new/git_hook.md +6 -0
- data/lib/terraspace/cli/help/new/module.md +9 -0
- data/lib/terraspace/cli/help/new/module_test.md +12 -0
- data/lib/terraspace/cli/help/new/plugin.md +49 -0
- data/lib/terraspace/cli/help/new/project.md +40 -0
- data/lib/terraspace/cli/help/new/project_test.md +8 -0
- data/lib/terraspace/cli/help/new/shim.md +21 -0
- data/lib/terraspace/cli/help/new/stack.md +9 -0
- data/lib/terraspace/cli/help/output.md +6 -0
- data/lib/terraspace/cli/help/plan.md +29 -0
- data/lib/terraspace/cli/help/providers.md +18 -0
- data/lib/terraspace/cli/help/refresh.md +11 -0
- data/lib/terraspace/cli/help/seed.md +7 -0
- data/lib/terraspace/cli/help/show.md +36 -0
- data/lib/terraspace/cli/help/summary.md +11 -0
- data/lib/terraspace/cli/help/test.md +35 -0
- data/lib/terraspace/cli/help/up.md +30 -0
- data/lib/terraspace/cli/help/validate.md +9 -0
- data/lib/terraspace/cli/info.rb +4 -16
- data/lib/terraspace/cli/init.rb +3 -7
- data/lib/terraspace/cli/list.rb +2 -1
- data/lib/terraspace/cli/logs.rb +106 -9
- data/lib/terraspace/cli/{log → logs}/concern.rb +1 -1
- data/lib/terraspace/cli/new.rb +18 -18
- data/lib/terraspace/cli/new/git_hook.rb +4 -1
- data/lib/terraspace/cli/new/helper.rb +9 -2
- data/lib/terraspace/cli/new/project.rb +1 -1
- data/lib/terraspace/cli/summary.rb +2 -2
- data/lib/terraspace/command.rb +1 -1
- data/lib/terraspace/compiler/dependencies/helpers.rb +34 -0
- data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +0 -26
- data/lib/terraspace/compiler/dsl/syntax/tfvar.rb +1 -0
- data/lib/terraspace/compiler/erb/context.rb +1 -1
- data/lib/terraspace/compiler/erb/helpers.rb +6 -0
- data/lib/terraspace/dependency/graph.rb +2 -1
- data/lib/terraspace/dependency/helper/base.rb +7 -0
- data/lib/terraspace/dependency/helper/depends_on.rb +12 -0
- data/lib/terraspace/dependency/helper/output.rb +11 -0
- data/lib/terraspace/hooks/builder.rb +52 -0
- data/lib/terraspace/hooks/concern.rb +9 -0
- data/lib/terraspace/{terraform/hooks → hooks}/dsl.rb +3 -2
- data/lib/terraspace/hooks/runner.rb +23 -0
- data/lib/terraspace/mod.rb +11 -2
- data/lib/terraspace/plugin/summary/interface.rb +4 -2
- data/lib/terraspace/shell.rb +29 -14
- data/lib/terraspace/terraform/args/custom.rb +1 -1
- data/lib/terraspace/terraform/cloud/runs/lister.rb +0 -2
- data/lib/terraspace/terraform/cloud/syncer.rb +2 -2
- data/lib/terraspace/terraform/cloud/workspace.rb +0 -9
- data/lib/terraspace/terraform/remote_state/fetcher.rb +13 -4
- data/lib/terraspace/terraform/remote_state/marker/output.rb +3 -1
- data/lib/terraspace/terraform/remote_state/output_proxy.rb +18 -14
- data/lib/terraspace/terraform/remote_state/unresolved.rb +40 -0
- data/lib/terraspace/terraform/runner.rb +2 -7
- data/lib/terraspace/version.rb +1 -1
- data/spec/fixtures/dependencies/app/stacks/a1/tfvars/dev.tfvars +1 -0
- data/spec/fixtures/fetcher/c1.json +4 -0
- data/spec/terraspace/all/summary_spec.rb +1 -1
- data/spec/terraspace/compiler/erb/render_spec.rb +15 -0
- data/spec/terraspace/dependency/helper/depends_on_spec.rb +27 -0
- data/spec/terraspace/dependency/helper/output_spec.rb +29 -0
- data/spec/terraspace/{terraform/hooks → hooks}/builder_spec.rb +4 -5
- data/spec/terraspace/terraform/remote_state/fetcher_spec.rb +108 -27
- data/spec/terraspace/terraform/remote_state/marker/output_spec.rb +36 -0
- data/spec/terraspace/terraform/remote_state/output_proxy_spec.rb +69 -0
- data/terraspace.gemspec +1 -1
- metadata +78 -13
- data/lib/terraspace/cli/help/log.md +0 -46
- data/lib/terraspace/cli/help/update.md +0 -5
- data/lib/terraspace/cli/log.rb +0 -112
- data/lib/terraspace/terraform/hooks/builder.rb +0 -40
@@ -1,4 +1,4 @@
|
|
1
|
-
module Terraspace::
|
1
|
+
module Terraspace::Hooks
|
2
2
|
module Dsl
|
3
3
|
def before(*commands, **props)
|
4
4
|
commands.each do |name|
|
@@ -13,7 +13,8 @@ module Terraspace::Terraform::Hooks
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def each_hook(type, name, props={})
|
16
|
-
@hooks[type][name]
|
16
|
+
@hooks[type][name] ||= []
|
17
|
+
@hooks[type][name] << props
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Terraspace::Hooks
|
2
|
+
class Runner
|
3
|
+
include Terraspace::Util
|
4
|
+
|
5
|
+
def initialize(mod, hook)
|
6
|
+
@mod, @hook = mod, hook
|
7
|
+
@execute = @hook["execute"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
case @execute
|
12
|
+
when String
|
13
|
+
Terraspace::Shell.new(@mod, @execute, exit_on_fail: @hook["exit_on_fail"]).run
|
14
|
+
when -> (e) { e.respond_to?(:public_instance_methods) && e.public_instance_methods.include?(:call) }
|
15
|
+
@execute.new.call
|
16
|
+
when -> (e) { e.respond_to?(:call) }
|
17
|
+
@execute.call
|
18
|
+
else
|
19
|
+
logger.warn "WARN: execute option not set for hook: #{@hook.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/terraspace/mod.rb
CHANGED
@@ -34,8 +34,17 @@ module Terraspace
|
|
34
34
|
Terraspace.check_project!
|
35
35
|
return if root
|
36
36
|
|
37
|
-
pretty_paths = paths.map { |p| Terraspace::Util.pretty_path(p) }
|
38
|
-
logger.error
|
37
|
+
pretty_paths = paths.map { |p| Terraspace::Util.pretty_path(p) }.join(", ")
|
38
|
+
logger.error <<~EOL
|
39
|
+
ERROR: Unable to find #{@name.color(:green)}. Searched paths:
|
40
|
+
|
41
|
+
#{pretty_paths}
|
42
|
+
|
43
|
+
To see available stacks, try running:
|
44
|
+
|
45
|
+
terraspace list
|
46
|
+
|
47
|
+
EOL
|
39
48
|
ENV['TS_TEST'] ? raise : exit(1)
|
40
49
|
end
|
41
50
|
|
@@ -18,7 +18,7 @@ module Terraspace::Plugin::Summary
|
|
18
18
|
# Note: will not change any of these instance variables unless we note breaking changes
|
19
19
|
@bucket = @info[bucket_field]
|
20
20
|
@key = @info[key_field] # key_field is INTERFACE METHOD IE: aws: key , google: prefix
|
21
|
-
@folder = folder(@key)
|
21
|
+
@folder = folder(@key) # useful as prefix for performance when listing objects in buckets
|
22
22
|
@dest = dest(@bucket)
|
23
23
|
# May change any of these instance variables that follow
|
24
24
|
@dest_folder = "#{@dest}/#{@folder}"
|
@@ -64,7 +64,9 @@ module Terraspace::Plugin::Summary
|
|
64
64
|
|
65
65
|
def show_each(path)
|
66
66
|
data = JSON.load(IO.read(path))
|
67
|
+
return unless data # edge case: blank file
|
67
68
|
resources = data['resources']
|
69
|
+
return unless resources
|
68
70
|
remove_statefile(path) if resources && resources.size == 0 && !ENV['TS_KEEP_EMPTY_STATEFILES']
|
69
71
|
return unless resources && resources.size > 0
|
70
72
|
|
@@ -75,7 +77,7 @@ module Terraspace::Plugin::Summary
|
|
75
77
|
identifier = r['instances'].map do |i|
|
76
78
|
i['attributes']['name'] || i['attributes']['id']
|
77
79
|
end.join(',')
|
78
|
-
return
|
80
|
+
return unless @options[:details]
|
79
81
|
logger.info " #{r['type']} #{r['name']}: #{identifier}"
|
80
82
|
end
|
81
83
|
end
|
data/lib/terraspace/shell.rb
CHANGED
@@ -6,26 +6,36 @@ module Terraspace
|
|
6
6
|
|
7
7
|
def initialize(mod, command, options={})
|
8
8
|
@mod, @command, @options = mod, command, options
|
9
|
-
|
9
|
+
# error_messages holds aggregation of all error lines
|
10
|
+
@known_error, @error_messages = nil, ''
|
10
11
|
end
|
11
12
|
|
12
13
|
# requires @mod to be set
|
14
|
+
# quiet useful for RemoteState::Fetcher
|
13
15
|
def run
|
14
|
-
env = @options[:env] || {}
|
15
|
-
env.stringify_keys!
|
16
|
-
|
17
|
-
# quiet useful for RemoteState::Fetcher
|
18
16
|
msg = "=> #{@command}"
|
19
17
|
@options[:quiet] ? logger.debug(msg) : logger.info(msg)
|
20
18
|
return if ENV['TS_TEST']
|
19
|
+
shell
|
20
|
+
end
|
21
|
+
|
22
|
+
def shell
|
23
|
+
env = @options[:env] || {}
|
24
|
+
env.stringify_keys!
|
25
|
+
if @options[:shell] == "system" # terraspace console
|
26
|
+
system(env, @command, chdir: @mod.cache_dir)
|
27
|
+
else
|
28
|
+
popen3(env)
|
29
|
+
end
|
30
|
+
end
|
21
31
|
|
32
|
+
def popen3(env)
|
22
33
|
Open3.popen3(env, @command, chdir: @mod.cache_dir) do |stdin, stdout, stderr, wait_thread|
|
23
34
|
mimic_terraform_input(stdin, stdout)
|
24
35
|
while err = stderr.gets
|
25
|
-
@
|
26
|
-
|
27
|
-
|
28
|
-
else
|
36
|
+
@error_messages << err # aggregate all error lines
|
37
|
+
@known_error ||= known_error_type(err)
|
38
|
+
unless @known_error
|
29
39
|
# Sometimes may print a "\e[31m\n" which like during dependencies fetcher init
|
30
40
|
# suppress it so dont get a bunch of annoying "newlines"
|
31
41
|
next if err == "\e[31m\n" && @options[:suppress_error_color]
|
@@ -39,8 +49,8 @@ module Terraspace
|
|
39
49
|
end
|
40
50
|
|
41
51
|
def known_error_type(err)
|
42
|
-
if
|
43
|
-
:
|
52
|
+
if reinit_required?(err)
|
53
|
+
:reinit_required
|
44
54
|
elsif bucket_not_found?(err)
|
45
55
|
:bucket_not_found
|
46
56
|
end
|
@@ -51,7 +61,12 @@ module Terraspace
|
|
51
61
|
err.include?("Failed to get existing workspaces")
|
52
62
|
end
|
53
63
|
|
54
|
-
def
|
64
|
+
def reinit_required?(err)
|
65
|
+
# Example error: https://gist.github.com/tongueroo/f7e0a44b64f0a2e533089b18f331c21e
|
66
|
+
squeezed = @error_messages.gsub("\n", ' ').squeeze(' ') # remove double whitespaces and newlines
|
67
|
+
general_check = squeezed.include?("terraform init") && squeezed.include?("Error:")
|
68
|
+
|
69
|
+
general_check ||
|
55
70
|
err.include?("reinitialization required") ||
|
56
71
|
err.include?("terraform init") ||
|
57
72
|
err.include?("require reinitialization")
|
@@ -61,9 +76,9 @@ module Terraspace
|
|
61
76
|
return if status == 0
|
62
77
|
|
63
78
|
exit_on_fail = @options[:exit_on_fail].nil? ? true : @options[:exit_on_fail]
|
64
|
-
if @
|
79
|
+
if @known_error == :reinit_required
|
65
80
|
raise InitRequiredError.new(@error_messages)
|
66
|
-
elsif @
|
81
|
+
elsif @known_error == :bucket_not_found
|
67
82
|
raise BucketNotFoundError.new(@error_messages)
|
68
83
|
elsif exit_on_fail
|
69
84
|
logger.error "Error running command: #{@command}".color(:red)
|
@@ -20,15 +20,6 @@ module Terraspace::Terraform::Cloud
|
|
20
20
|
logger.info names.join("\n")
|
21
21
|
end
|
22
22
|
|
23
|
-
def setup
|
24
|
-
build
|
25
|
-
unless backend.dig('remote','workspaces') # in case called by terraspace down demo -y --destroy-workspace with a non-remote backend
|
26
|
-
logger.info "ERROR: Workspace not configured in backend.tf"
|
27
|
-
exit 1
|
28
|
-
end
|
29
|
-
init
|
30
|
-
end
|
31
|
-
|
32
23
|
def init
|
33
24
|
Terraspace::CLI::Init.new(@options.merge(calling_command: "cloud-setup")).run
|
34
25
|
end
|
@@ -8,6 +8,7 @@ module Terraspace::Terraform::RemoteState
|
|
8
8
|
@parent, @identifier, @options = parent, identifier, options
|
9
9
|
child_name, @output_key = identifier.split('.')
|
10
10
|
@child = Terraspace::Mod.new(child_name)
|
11
|
+
@child.resolved = @parent.resolved
|
11
12
|
end
|
12
13
|
|
13
14
|
def run
|
@@ -16,16 +17,24 @@ module Terraspace::Terraform::RemoteState
|
|
16
17
|
load
|
17
18
|
end
|
18
19
|
|
20
|
+
# Returns OutputProxy
|
19
21
|
def output
|
20
22
|
run
|
21
23
|
if pull_success?
|
22
|
-
|
23
|
-
error = output_error(:key_not_found) unless @outputs.key?(@output_key)
|
24
|
-
OutputProxy.new(value, @options.merge(error: error))
|
24
|
+
pull_success_output
|
25
25
|
else
|
26
26
|
@error_type ||= :state_not_found # could be set to :bucket_not_found by bucket_not_found_error
|
27
27
|
error = output_error(@error_type)
|
28
|
-
OutputProxy.new(nil, @options.merge(error: error))
|
28
|
+
OutputProxy.new(@child, nil, @options.merge(error: error))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def pull_success_output
|
33
|
+
if @outputs.key?(@output_key)
|
34
|
+
OutputProxy.new(@child, output_value, @options)
|
35
|
+
else
|
36
|
+
error = output_error(:key_not_found)
|
37
|
+
OutputProxy.new(@child, nil, @options.merge(error: error))
|
29
38
|
end
|
30
39
|
end
|
31
40
|
|
@@ -8,6 +8,7 @@ module Terraspace::Terraform::RemoteState::Marker
|
|
8
8
|
@child_name, @output_key = @identifier.split('.')
|
9
9
|
end
|
10
10
|
|
11
|
+
# Returns OutputProxy
|
11
12
|
def build
|
12
13
|
if valid?
|
13
14
|
Terraspace::Dependency::Registry.register(@parent_name, @child_name)
|
@@ -16,7 +17,7 @@ module Terraspace::Terraform::RemoteState::Marker
|
|
16
17
|
end
|
17
18
|
# MARKER for debugging. Only appears on 1st pass. Will not see unless changing Terraspace code for debugging.
|
18
19
|
marker = "MARKER:terraform_output('#{@identifier}')"
|
19
|
-
Terraspace::Terraform::RemoteState::OutputProxy.new(marker, @options)
|
20
|
+
Terraspace::Terraform::RemoteState::OutputProxy.new(@mod, marker, @options)
|
20
21
|
end
|
21
22
|
|
22
23
|
def valid?
|
@@ -26,6 +27,7 @@ module Terraspace::Terraform::RemoteState::Marker
|
|
26
27
|
def warning
|
27
28
|
logger.warn "WARN: The #{@child_name} stack does not exist".color(:yellow)
|
28
29
|
caller_line = caller.find { |l| l.include?('.tfvars') }
|
30
|
+
return unless caller_line # specs dont have a tfvars file
|
29
31
|
source_code = PrettyTracer.new(caller_line).source_code
|
30
32
|
logger.info source_code
|
31
33
|
end
|
@@ -1,29 +1,33 @@
|
|
1
1
|
module Terraspace::Terraform::RemoteState
|
2
2
|
class OutputProxy
|
3
3
|
# raw: can be anything: String, Array, Hash, etc
|
4
|
-
# options: original options passed by user
|
4
|
+
# options: original options passed by user from the output helper in tfvars
|
5
5
|
attr_reader :raw, :options
|
6
|
-
def initialize(raw, options={})
|
7
|
-
@raw, @options = raw, options
|
6
|
+
def initialize(mod, raw, options={})
|
7
|
+
@mod, @raw, @options = mod, raw, options
|
8
8
|
@format = @options[:format]
|
9
9
|
end
|
10
10
|
|
11
11
|
# Should always return a String
|
12
12
|
def to_s
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
if @mod.resolved
|
14
|
+
# Dont use Unresolved wrapper because Integer get changed to Strings.
|
15
|
+
# Want raw value to be used for the to_json call
|
16
|
+
value = @raw.nil? ? mock_or_error : @raw
|
17
|
+
value.to_json
|
18
|
+
else
|
19
|
+
Unresolved.new
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def to_ruby
|
24
|
+
data = @raw.nil? ? mock_or_error : @raw
|
25
|
+
@mod.resolved ? data : Unresolved.new
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def mock_or_error
|
30
|
+
@options[:mock] || @options[:error]
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Terraspace::Terraform::RemoteState
|
2
|
+
class Unresolved
|
3
|
+
def to_a
|
4
|
+
[]
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_ary
|
8
|
+
[]
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
"(unresolved)" # always returned as part of first unresolved processing pass
|
13
|
+
end
|
14
|
+
alias_method :to_str, :to_s # ERB requires to_str
|
15
|
+
|
16
|
+
def to_f
|
17
|
+
0.0
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_i
|
21
|
+
0
|
22
|
+
end
|
23
|
+
|
24
|
+
def nil?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
def inspect
|
29
|
+
format("#<%s:0x%x>", self.class, object_id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def method_missing(*_args, &_block)
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def respond_to?(_message, _include_private = false)
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Terraspace::Terraform
|
2
2
|
class Runner < Terraspace::CLI::Base
|
3
3
|
extend Memoist
|
4
|
+
include Terraspace::Hooks::Concern
|
4
5
|
include Terraspace::Util
|
5
6
|
|
6
7
|
attr_reader :name
|
@@ -21,7 +22,7 @@ module Terraspace::Terraform
|
|
21
22
|
|
22
23
|
params = args.flatten.join(' ')
|
23
24
|
command = "terraform #{name} #{params}"
|
24
|
-
run_hooks(name) do
|
25
|
+
run_hooks("terraform.rb", name) do
|
25
26
|
Terraspace::Shell.new(@mod, command, @options.merge(env: custom.env_vars)).run
|
26
27
|
end
|
27
28
|
rescue Terraspace::InitRequiredError => e
|
@@ -53,12 +54,6 @@ module Terraspace::Terraform
|
|
53
54
|
@options[:quiet] ? logger.debug(msg) : logger.info(msg)
|
54
55
|
end
|
55
56
|
|
56
|
-
def run_hooks(name, &block)
|
57
|
-
hooks = Hooks::Builder.new(@mod, name)
|
58
|
-
hooks.build # build hooks
|
59
|
-
hooks.run_hooks(&block)
|
60
|
-
end
|
61
|
-
|
62
57
|
def args
|
63
58
|
# base at end in case of redirection. IE: terraform output > /path
|
64
59
|
custom.args + custom.var_files + default.args
|
data/lib/terraspace/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
length = <%= output('b1.length') %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Terraspace::Compiler::Erb::Render do
|
2
|
+
let(:render) { described_class.new(mod, src_path) }
|
3
|
+
let(:mod) { Terraspace::Mod.new("a1") }
|
4
|
+
|
5
|
+
# Only testing mod unresolved as a sanity check and its worth the ROI.
|
6
|
+
# The resolved would the Fetcher. We have unit tests to cover those other changes.
|
7
|
+
context "a1" do
|
8
|
+
let(:src_path) { fixture("dependencies/app/stacks/a1/tfvars/dev.tfvars") }
|
9
|
+
it "build" do
|
10
|
+
allow(Terraspace::Terraform::RemoteState::Marker::Output).to receive(:stack_names).and_return("b1")
|
11
|
+
result = render.build
|
12
|
+
expect(result).to eq "length = (unresolved)"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|