Class: Genesis::Cli
Instance Method Summary
collapse
Methods included from Commands
#apply_command, #apply_plan_command, #destroy_plan_command, #plan_command, #refresh_command, #show_command
Constructor Details
#initialize(*args) ⇒ Cli
Returns a new instance of Cli.
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/genesis/cli.rb', line 65
def initialize(*args)
super
@aws_access_key = ENV['AWS_ACCESS_KEY']
@aws_secret_key = ENV['AWS_SECRET_KEY']
@aws_key_pair = ENV['AWS_KEY_PAIR']
@prompt = options[:prompt]
@terraform_dir = options[:terraform_dir]
@vars = options[:vars]
validate_environment_variables
validate_path
validate_terraform_directory
end
|
Instance Method Details
#apply ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/genesis/cli.rb', line 19
def apply
confirmed = if @prompt
message = 'Are you sure you want to apply changes? (y/n)'
yes?(message, :red)
else
true
end
system apply_command if confirmed
end
|
#destroy ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/genesis/cli.rb', line 36
def destroy
plan_created = system destroy_plan_command
exit(1) unless plan_created
confirmed = if @prompt
yes?('Are you sure you want to destroy infrastructure? (y/n)', :red)
else
true
end
system apply_plan_command if confirmed
File.delete(plan_file) if File.exist?(plan_file)
end
|
#plan ⇒ Object
14
15
16
|
# File 'lib/genesis/cli.rb', line 14
def plan
system plan_command
end
|
#refresh ⇒ Object
9
10
11
|
# File 'lib/genesis/cli.rb', line 9
def refresh
system refresh_command
end
|
#show ⇒ Object
31
32
33
|
# File 'lib/genesis/cli.rb', line 31
def show
system show_command
end
|