Class: Terradactyl::Stack
- Inherits:
-
Object
- Object
- Terradactyl::Stack
show all
- Includes:
- Common
- Defined in:
- lib/terradactyl/stack.rb
Constant Summary
Constants included
from Common
Common::BORDER_CHAR, Common::COLUMN_WIDTH
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Common
border, centre, config, cputs, dot_icon, print_content, print_crit, print_dot, print_header, print_line, print_message, print_ok, print_warning, required_versions_re, stack_icon, supported_revisions, tag, terraform_binary
Constructor Details
#initialize(stack_name, base_override = nil) ⇒ Stack
Returns a new instance of Stack.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/terradactyl/stack.rb', line 13
def initialize(stack_name, base_override = nil)
if base_override
config.merge_overlay(base_override)
else
config.reload
end
@stack_name = validate_stack_name(stack_name)
@base_override = base_override
@stack_config = ConfigStack.new(@stack_name, @base_override)
@tf_version = tf_version
Commands.extend_by_revision(@tf_version, self)
print_message "Terraform version: #{@tf_version}"
inject_env_vars
rescue NameError
print_crit "Unsupported Terraform version: #{@tf_version}"
Stacks.error!(stack_name)
throw :error
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
129
130
131
132
133
|
# File 'lib/terradactyl/stack.rb', line 129
def method_missing(sym, *args, &block)
config.send(sym.to_sym, *args, &block)
rescue NameError
super
end
|
Instance Attribute Details
#stack_config ⇒ Object
Returns the value of attribute stack_config.
7
8
9
|
# File 'lib/terradactyl/stack.rb', line 7
def stack_config
@stack_config
end
|
Class Method Details
.load(stack_name) ⇒ Object
9
10
11
|
# File 'lib/terradactyl/stack.rb', line 9
def self.load(stack_name)
new(stack_name)
end
|
Instance Method Details
#<=>(other) ⇒ Object
38
39
40
|
# File 'lib/terradactyl/stack.rb', line 38
def <=>(other)
name <=> other.name
end
|
#config ⇒ Object
34
35
36
|
# File 'lib/terradactyl/stack.rb', line 34
def config
stack_config || super
end
|
#plan_file_obj ⇒ Object
63
64
65
|
# File 'lib/terradactyl/stack.rb', line 63
def plan_file_obj
@plan_file_obj ||= load_plan_file
end
|
#planned? ⇒ Boolean
46
47
48
|
# File 'lib/terradactyl/stack.rb', line 46
def planned?
File.exist?(plan_path)
end
|
#print_error ⇒ Object
59
60
61
|
# File 'lib/terradactyl/stack.rb', line 59
def print_error
print_content(plan_file_obj.error_output)
end
|
#print_plan ⇒ Object
55
56
57
|
# File 'lib/terradactyl/stack.rb', line 55
def print_plan
print_content(plan_file_obj.plan_output)
end
|
#remove_plan_file ⇒ Object
50
51
52
53
|
# File 'lib/terradactyl/stack.rb', line 50
def remove_plan_file
print_dot("Removing Plan File: #{plan_file}", :light_yellow)
FileUtils.rm_rf(plan_path)
end
|
#to_s ⇒ Object
42
43
44
|
# File 'lib/terradactyl/stack.rb', line 42
def to_s
"<name: #{name}, path: #{path}>"
end
|