4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/proteus/commands/apply.rb', line 4
def self.included(thor_class)
thor_class.class_eval do
desc 'apply', 'Applies the current terraform code'
long_desc <<-LONGDESC
Applies the current terraform code
LONGDESC
def apply
init(verbose: parent_options[:verbose])
confirm question: "Do you really want to run 'terraform apply' on environment '#{environment}' in context '#{context}'?", color: :on_red, exit_code: 0 do
if !options[:dryrun]
slack_notification(
context: context,
environment: environment,
message: 'is running terraform apply. Wait for it.'
)
end
apply_command = <<~APPLY_COMMAND
cd #{context_path(context)} && \
terraform apply \
-input=true \
-refresh=true \
#{plan_file(context, environment)}
APPLY_COMMAND
syscall apply_command.squeeze(' '), dryrun: dryrun
if !options[:dryrun]
slack_notification(
context: context,
environment: environment,
message: 'applied a new version of me!'
)
end
end
end
end
end
|