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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1618948f7193a77820ab055cb59b3ffd127b41e7
4
- data.tar.gz: a560d1085e763d45adec28af6c02fa0dfcc2a538
3
+ metadata.gz: 6531669f295b2887262b4100570eef51bbde0967
4
+ data.tar.gz: 5033f138be958a3c235d119397c3e66f44f49cba
5
5
  SHA512:
6
- metadata.gz: 19239c14c4b0d570a3902097227aa905927597c8ffc3b18e73ecd45582a62b99acd64b9d087ab2351da506b3bc71d7f37559ed149f0a173490cccad5f8dcc6c5
7
- data.tar.gz: df4ea705aaf38036ceb276b0f6054f9b182cf80f1e7531387b8feb4767746fb25eb2a002edf6ccabbc1368131a4fca99b37ebeef39316312ffd57cd25cb2aa49
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
- system apply_command if confirmed
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
@@ -3,64 +3,80 @@ require 'thor'
3
3
  module Genesis
4
4
  module Commands
5
5
  def destroy_plan_command
6
- %W[
7
- terraform plan
8
- -var "aws_access_key=#{@aws_access_key}"
9
- -var "aws_secret_key=#{@aws_secret_key}"
10
- -var "aws_key_pair=#{@aws_key_pair}"
11
- -refresh=true
12
- -destroy
13
- -state=#{state_file}
14
- -out=#{plan_file}
15
- #{terraform_dir}
16
- ].join(' ')
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
- %W[
29
- terraform apply
30
- -var "aws_access_key=#{@aws_access_key}"
31
- -var "aws_secret_key=#{@aws_secret_key}"
32
- -var "aws_key_pair=#{@aws_key_pair}"
33
- -refresh=true
34
- -state=#{state_file}
35
- #{terraform_dir}
36
- ].join(' ')
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
- %W[
41
- terraform refresh
42
- -var "aws_access_key=#{@aws_access_key}"
43
- -var "aws_secret_key=#{@aws_secret_key}"
44
- -var "aws_key_pair=#{@aws_key_pair}"
45
- -state=#{state_file}
46
- #{terraform_dir}
47
- ].join(' ')
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 plan
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
- #{terraform_dir}
62
+ #{plan_file}
59
63
  ].join(' ')
60
64
  end
61
65
 
62
- def show_command
63
- "terraform show #{state_file}"
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
@@ -1,3 +1,3 @@
1
1
  module Genesis
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genesis_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Cross