Module: Terradactyl::Commands
Overview
rubocop:disable Metrics/ModuleLength
Defined Under Namespace
Modules: Rev011, Rev012, Rev013, Rev014, Rev015, Rev1_00, Rev1_01, Rev1_02, Rev1_03, Rev1_04, Rev1_05, Rev1_06, Rev1_07, Rev1_08, Rev1_latest
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.extend_by_revision(tf_version, object) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/terradactyl/commands.rb', line 59
def extend_by_revision(tf_version, object)
anon_module = revision_module
begin
revision = revision_constant(tf_version)
rescue NameError
revision = revision_constant(major_revision(tf_version))
end
anon_module.include(self)
anon_module.prepend(revision)
object.class.define_singleton_method(:revision) { revision }
object.define_singleton_method(:revision) { revision }
object.extend(anon_module)
end
|
Instance Method Details
#apply ⇒ Object
148
149
150
|
# File 'lib/terradactyl/commands.rb', line 148
def apply
Apply.execute(dir_or_plan: plan_file, options: command_options)
end
|
#clean ⇒ Object
rubocop:disable Metrics/AbcSize
176
177
178
179
180
181
182
183
184
|
# File 'lib/terradactyl/commands.rb', line 176
def clean
removals = config.cleanup.match.map { |p| Dir.glob("**/#{p}") }
removals << `find . -type d -empty`.split if config.cleanup.empty
removals = removals.flatten.sort.uniq.each do |trash|
print_dot("Removing: #{trash}", :light_yellow)
FileUtils.rm_rf(trash)
end
puts unless removals.empty?
end
|
#destroy ⇒ Object
157
158
159
160
|
# File 'lib/terradactyl/commands.rb', line 157
def destroy
options = command_options.tap { |dat| dat.state = state_file }
Destroy.execute(dir_or_plan: nil, options: options)
end
|
#fmt ⇒ Object
167
168
169
|
# File 'lib/terradactyl/commands.rb', line 167
def fmt
Fmt.execute(dir_or_plan: nil, options: command_options)
end
|
#init ⇒ Object
118
119
120
|
# File 'lib/terradactyl/commands.rb', line 118
def init
Init.execute(dir_or_plan: nil, options: command_options)
end
|
#lint ⇒ Object
162
163
164
165
|
# File 'lib/terradactyl/commands.rb', line 162
def lint
options = command_options.tap { |dat| dat.check = true }
Fmt.execute(dir_or_plan: nil, options: options)
end
|
#plan ⇒ Object
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/terradactyl/commands.rb', line 122
def plan
options = command_options.tap do |dat|
dat.state = state_file
dat.out = plan_file
dat.no_color = true
end
captured = Plan.execute(dir_or_plan: nil,
options: options,
capture: true)
@plan_file_obj = load_plan_file
case captured.exitstatus
when 0
'No changes. Infrastructure is up-to-date.'
when 1
@plan_file_obj.error_output = captured.stderr
when 2
@plan_file_obj.plan_output = captured.stdout
@plan_file_obj.save
end
captured.exitstatus
end
|
#refresh ⇒ Object
152
153
154
155
|
# File 'lib/terradactyl/commands.rb', line 152
def refresh
options = command_options.tap { |dat| dat.state = state_file }
Refresh.execute(dir_or_plan: nil, options: options)
end
|
#upgrade ⇒ Object
rubocop:enable Metrics/AbcSize
187
188
189
|
# File 'lib/terradactyl/commands.rb', line 187
def upgrade
perform_upgrade
end
|
#validate ⇒ Object
171
172
173
|
# File 'lib/terradactyl/commands.rb', line 171
def validate
Validate.execute(dir_or_plan: nil, options: command_options)
end
|