genesis_cli 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/genesis/cli.rb +9 -1
- data/lib/genesis/commands.rb +60 -44
- data/lib/genesis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6531669f295b2887262b4100570eef51bbde0967
|
4
|
+
data.tar.gz: 5033f138be958a3c235d119397c3e66f44f49cba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144c3468b841185a7700b37075d4c32708120776faab9807e1433bca3bf8f918a9fd2aee7d80d8f2bbd3f80a94e29bccd4c8edc1040226b3c7e6cb3e4ddc4633
|
7
|
+
data.tar.gz: c62afa6556d7e7d7439390a86bfd8dd451b158c17314da77cfda49cb6579dda3bf580ad3cb7544f09b2210379a297710c564ddd9ce0cb8a593bdb5a8f1624b66
|
data/lib/genesis/cli.rb
CHANGED
@@ -24,7 +24,8 @@ module Genesis
|
|
24
24
|
true
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
puts apply_command
|
28
|
+
# system apply_command if confirmed
|
28
29
|
end
|
29
30
|
|
30
31
|
desc 'show', 'Output contents of the state file'
|
@@ -56,6 +57,12 @@ module Genesis
|
|
56
57
|
default: File.join(Dir.pwd, 'terraform'),
|
57
58
|
desc: 'Directory where terraform files can be found'
|
58
59
|
}
|
60
|
+
option :vars, {
|
61
|
+
required: true,
|
62
|
+
type: :hash,
|
63
|
+
default: {},
|
64
|
+
desc: "Adds additional variables for a Terraform command."
|
65
|
+
}
|
59
66
|
def initialize(*args)
|
60
67
|
super
|
61
68
|
|
@@ -64,6 +71,7 @@ module Genesis
|
|
64
71
|
@aws_key_pair = ENV['AWS_KEY_PAIR']
|
65
72
|
@prompt = options[:prompt]
|
66
73
|
@terraform_dir = options[:terraform_dir]
|
74
|
+
@vars = options[:vars]
|
67
75
|
|
68
76
|
validate_environment_variables
|
69
77
|
validate_path
|
data/lib/genesis/commands.rb
CHANGED
@@ -3,64 +3,80 @@ require 'thor'
|
|
3
3
|
module Genesis
|
4
4
|
module Commands
|
5
5
|
def destroy_plan_command
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def apply_plan_command
|
20
|
-
%W[
|
21
|
-
terraform apply
|
22
|
-
-state=#{state_file}
|
23
|
-
#{plan_file}
|
24
|
-
].join(' ')
|
6
|
+
command = []
|
7
|
+
command << 'terraform plan'
|
8
|
+
command << variables
|
9
|
+
command.flatten!
|
10
|
+
command << '-refresh=true'
|
11
|
+
command << '-destroy'
|
12
|
+
command << "-state=#{state_file}"
|
13
|
+
command << "-out=#{plan_file}"
|
14
|
+
command << "#{@terraform_dir}"
|
15
|
+
|
16
|
+
command.join(' ')
|
25
17
|
end
|
26
18
|
|
27
19
|
def apply_command
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
20
|
+
command = []
|
21
|
+
command << 'terraform apply'
|
22
|
+
command << variables
|
23
|
+
command.flatten!
|
24
|
+
command << '-refresh=true'
|
25
|
+
command << "-state=#{state_file}"
|
26
|
+
command << "#{@terraform_dir}"
|
27
|
+
|
28
|
+
command.join(' ')
|
37
29
|
end
|
38
30
|
|
39
31
|
def refresh_command
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
32
|
+
command = []
|
33
|
+
command << 'terraform refresh'
|
34
|
+
command << variables
|
35
|
+
command.flatten!
|
36
|
+
command << "-state=#{state_file}"
|
37
|
+
command << "#{@terraform_dir}"
|
38
|
+
|
39
|
+
command.join(' ')
|
48
40
|
end
|
49
41
|
|
50
42
|
def plan_command
|
43
|
+
command = []
|
44
|
+
command << 'terraform plan'
|
45
|
+
command << variables
|
46
|
+
command.flatten!
|
47
|
+
command << '-refresh=true'
|
48
|
+
command << "-state=#{state_file}"
|
49
|
+
command << "#{@terraform_dir}"
|
50
|
+
|
51
|
+
command.join(' ')
|
52
|
+
end
|
53
|
+
|
54
|
+
def show_command
|
55
|
+
"terraform show #{state_file}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def apply_plan_command
|
51
59
|
%W[
|
52
|
-
terraform
|
53
|
-
-var "aws_access_key=#{@aws_access_key}"
|
54
|
-
-var "aws_secret_key=#{@aws_secret_key}"
|
55
|
-
-var "aws_key_pair=#{@aws_key_pair}"
|
56
|
-
-refresh=true
|
60
|
+
terraform apply
|
57
61
|
-state=#{state_file}
|
58
|
-
#{
|
62
|
+
#{plan_file}
|
59
63
|
].join(' ')
|
60
64
|
end
|
61
65
|
|
62
|
-
|
63
|
-
|
66
|
+
private
|
67
|
+
|
68
|
+
def variables
|
69
|
+
defaults = {
|
70
|
+
aws_access_key: @aws_access_key,
|
71
|
+
aws_secret_key: @aws_secret_key,
|
72
|
+
aws_key_pair: @aws_key_pair
|
73
|
+
}
|
74
|
+
|
75
|
+
variables = defaults.merge(@vars)
|
76
|
+
|
77
|
+
variables.reduce([]) do |data, (name, value)|
|
78
|
+
data << "-var \"#{name}=#{value}\""
|
79
|
+
end
|
64
80
|
end
|
65
81
|
end
|
66
82
|
end
|
data/lib/genesis/version.rb
CHANGED