ruby-terraform 0.62.0 → 0.65.0.pre.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +111 -32
  3. data/README.md +29 -9
  4. data/Rakefile +81 -37
  5. data/bin/console +3 -3
  6. data/lib/ruby-terraform.rb +1 -1
  7. data/lib/ruby_terraform.rb +1 -1
  8. data/lib/ruby_terraform/commands/apply.rb +24 -24
  9. data/lib/ruby_terraform/commands/base.rb +12 -14
  10. data/lib/ruby_terraform/commands/clean.rb +2 -2
  11. data/lib/ruby_terraform/commands/destroy.rb +24 -24
  12. data/lib/ruby_terraform/commands/format.rb +0 -1
  13. data/lib/ruby_terraform/commands/get.rb +7 -8
  14. data/lib/ruby_terraform/commands/import.rb +1 -1
  15. data/lib/ruby_terraform/commands/init.rb +22 -16
  16. data/lib/ruby_terraform/commands/output.rb +1 -2
  17. data/lib/ruby_terraform/commands/plan.rb +24 -23
  18. data/lib/ruby_terraform/commands/refresh.rb +22 -21
  19. data/lib/ruby_terraform/commands/remote_config.rb +12 -12
  20. data/lib/ruby_terraform/commands/show.rb +0 -1
  21. data/lib/ruby_terraform/commands/validate.rb +20 -19
  22. data/lib/ruby_terraform/commands/workspace.rb +4 -7
  23. data/lib/ruby_terraform/errors/execution_error.rb +1 -1
  24. data/lib/ruby_terraform/version.rb +1 -1
  25. metadata +111 -43
  26. data/.circleci/config.yml +0 -56
  27. data/.circleci/gpg.private.enc +0 -0
  28. data/.envrc +0 -5
  29. data/.git-crypt/.gitattributes +0 -4
  30. data/.git-crypt/keys/default/0/41D2606F66C3FF28874362B61A16916844CE9D82.gpg +0 -0
  31. data/.git-crypt/keys/default/0/AAE932B730C2BA697FFDFAE05DA390873E38358B.gpg +0 -0
  32. data/.gitattributes +0 -1
  33. data/.gitignore +0 -31
  34. data/.rspec +0 -2
  35. data/.ruby-version +0 -1
  36. data/CHANGELOG.md +0 -44
  37. data/TODO.md +0 -1
  38. data/config/secrets/.unlocked +0 -1
  39. data/config/secrets/ci/encryption.passphrase +0 -1
  40. data/config/secrets/ci/gpg.private +0 -58
  41. data/config/secrets/ci/gpg.public +0 -31
  42. data/config/secrets/ci/ssh.private +0 -51
  43. data/config/secrets/ci/ssh.public +0 -1
  44. data/config/secrets/circle_ci/config.yaml +0 -2
  45. data/config/secrets/github/config.yaml +0 -2
  46. data/config/secrets/rubygems/credentials +0 -2
  47. data/go +0 -56
  48. data/ruby_terraform.gemspec +0 -37
  49. data/scripts/ci/common/configure-git.sh +0 -8
  50. data/scripts/ci/common/configure-rubygems.sh +0 -16
  51. data/scripts/ci/common/install-git-crypt.sh +0 -8
  52. data/scripts/ci/common/install-gpg-key.sh +0 -19
  53. data/scripts/ci/steps/prerelease.sh +0 -16
  54. data/scripts/ci/steps/release.sh +0 -18
  55. data/scripts/ci/steps/test.sh +0 -12
@@ -1,3 +1,3 @@
1
1
  # Enable `require 'ruby-terraform'`, to match the gem name
2
2
 
3
- require_relative 'ruby_terraform.rb'
3
+ require_relative 'ruby_terraform'
@@ -107,7 +107,7 @@ module RubyTerraform
107
107
  end
108
108
 
109
109
  def write(*args)
110
- @targets.each {|t| t.write(*args)}
110
+ @targets.each { |t| t.write(*args) }
111
111
  end
112
112
 
113
113
  def close
@@ -1,5 +1,4 @@
1
1
  require 'json'
2
- require 'lino'
3
2
  require_relative 'base'
4
3
 
5
4
  module RubyTerraform
@@ -21,29 +20,30 @@ module RubyTerraform
21
20
  no_color = opts[:no_color]
22
21
 
23
22
  builder
24
- .with_subcommand('apply') do |sub|
25
- vars.each do |key, value|
26
- var_value = value.is_a?(String) ? value : JSON.generate(value)
27
- sub = sub.with_option(
28
- '-var', "'#{key}=#{var_value}'", separator: ' ')
29
- end
30
- sub = sub.with_option('-var-file', var_file) if var_file
31
- var_files.each do |file|
32
- sub = sub.with_option('-var-file', file)
33
- end
34
- sub = sub.with_option('-target', target) if target
35
- targets.each do |file|
36
- sub = sub.with_option('-target', file)
37
- end
38
- sub = sub.with_option('-state', state) if state
39
- sub = sub.with_option('-input', input) if input
40
- sub = sub.with_option('-auto-approve', auto_approve) unless
41
- auto_approve.nil?
42
- sub = sub.with_option('-backup', backup) if backup
43
- sub = sub.with_flag('-no-color') if no_color
44
- sub
45
- end
46
- .with_argument(plan || directory)
23
+ .with_subcommand('apply') do |sub|
24
+ vars.each do |key, value|
25
+ var_value = value.is_a?(String) ? value : JSON.generate(value)
26
+ sub = sub.with_option(
27
+ '-var', "'#{key}=#{var_value}'", separator: ' '
28
+ )
29
+ end
30
+ sub = sub.with_option('-var-file', var_file) if var_file
31
+ var_files.each do |file|
32
+ sub = sub.with_option('-var-file', file)
33
+ end
34
+ sub = sub.with_option('-target', target) if target
35
+ targets.each do |file|
36
+ sub = sub.with_option('-target', file)
37
+ end
38
+ sub = sub.with_option('-state', state) if state
39
+ sub = sub.with_option('-input', input) if input
40
+ sub = sub.with_option('-auto-approve', auto_approve) unless
41
+ auto_approve.nil?
42
+ sub = sub.with_option('-backup', backup) if backup
43
+ sub = sub.with_flag('-no-color') if no_color
44
+ sub
45
+ end
46
+ .with_argument(plan || directory)
47
47
  end
48
48
  end
49
49
  end
@@ -5,7 +5,8 @@ module RubyTerraform
5
5
  module Commands
6
6
  class Base
7
7
  def initialize(
8
- binary: nil, logger: nil, stdin: nil, stdout: nil, stderr: nil)
8
+ binary: nil, logger: nil, stdin: nil, stdout: nil, stderr: nil
9
+ )
9
10
  @binary = binary || RubyTerraform.configuration.binary
10
11
  @logger = logger || RubyTerraform.configuration.logger
11
12
  @stdin = stdin || RubyTerraform.configuration.stdin
@@ -18,12 +19,12 @@ module RubyTerraform
18
19
 
19
20
  do_before(opts)
20
21
  command = configure_command(builder, opts).build
21
- logger.debug("Running '#{command.to_s}'.")
22
+ logger.debug("Running '#{command}'.")
22
23
 
23
24
  command.execute(
24
- stdin: stdin,
25
- stdout: stdout,
26
- stderr: stderr
25
+ stdin: stdin,
26
+ stdout: stdout,
27
+ stderr: stderr
27
28
  )
28
29
  do_after(opts)
29
30
  rescue Open4::SpawnError
@@ -37,23 +38,20 @@ module RubyTerraform
37
38
  attr_reader :binary, :logger, :stdin, :stdout, :stderr
38
39
 
39
40
  def command_name
40
- self.class.to_s.split("::")[-1].downcase
41
+ self.class.to_s.split('::')[-1].downcase
41
42
  end
42
43
 
43
44
  def instantiate_builder
44
45
  Lino::CommandLineBuilder
45
- .for_command(binary)
46
- .with_option_separator('=')
46
+ .for_command(binary)
47
+ .with_option_separator('=')
47
48
  end
48
49
 
49
- def do_before(opts)
50
- end
50
+ def do_before(opts); end
51
51
 
52
- def configure_command(builder, opts)
53
- end
52
+ def configure_command(builder, opts); end
54
53
 
55
- def do_after(opts)
56
- end
54
+ def do_after(opts); end
57
55
  end
58
56
  end
59
57
  end
@@ -6,7 +6,7 @@ module RubyTerraform
6
6
  attr_reader :logger
7
7
 
8
8
  def initialize(directory: nil, logger: nil)
9
- @directory = directory ? directory : '.terraform'
9
+ @directory = directory || '.terraform'
10
10
  @logger = logger || RubyTerraform.configuration.logger
11
11
  end
12
12
 
@@ -14,7 +14,7 @@ module RubyTerraform
14
14
  directory = opts[:directory] || @directory
15
15
  begin
16
16
  logger.info "Cleaning terraform directory '#{directory}'."
17
- FileUtils.rm_r(directory, :secure => true)
17
+ FileUtils.rm_r(directory, secure: true)
18
18
  rescue Errno::ENOENT => e
19
19
  logger.error "Couldn't clean '#{directory}': #{e.message}"
20
20
  end
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -19,29 +18,30 @@ module RubyTerraform
19
18
  auto_approve = opts[:auto_approve]
20
19
 
21
20
  builder
22
- .with_subcommand('destroy') do |sub|
23
- vars.each do |key, value|
24
- var_value = value.is_a?(String) ? value : JSON.generate(value)
25
- sub = sub.with_option(
26
- '-var', "'#{key}=#{var_value}'", separator: ' ')
27
- end
28
- sub = sub.with_option('-var-file', var_file) if var_file
29
- var_files.each do |file|
30
- sub = sub.with_option('-var-file', file)
31
- end
32
- sub = sub.with_option('-target', target) if target
33
- targets.each do |target_name|
34
- sub = sub.with_option('-target', target_name)
35
- end
36
- sub = sub.with_option('-state', state) if state
37
- sub = sub.with_option('-auto-approve', auto_approve) unless
38
- auto_approve.nil?
39
- sub = sub.with_option('-backup', backup) if backup
40
- sub = sub.with_flag('-no-color') if no_color
41
- sub = sub.with_flag('-force') if force
42
- sub
43
- end
44
- .with_argument(directory)
21
+ .with_subcommand('destroy') do |sub|
22
+ vars.each do |key, value|
23
+ var_value = value.is_a?(String) ? value : JSON.generate(value)
24
+ sub = sub.with_option(
25
+ '-var', "'#{key}=#{var_value}'", separator: ' '
26
+ )
27
+ end
28
+ sub = sub.with_option('-var-file', var_file) if var_file
29
+ var_files.each do |file|
30
+ sub = sub.with_option('-var-file', file)
31
+ end
32
+ sub = sub.with_option('-target', target) if target
33
+ targets.each do |target_name|
34
+ sub = sub.with_option('-target', target_name)
35
+ end
36
+ sub = sub.with_option('-state', state) if state
37
+ sub = sub.with_option('-auto-approve', auto_approve) unless
38
+ auto_approve.nil?
39
+ sub = sub.with_option('-backup', backup) if backup
40
+ sub = sub.with_flag('-no-color') if no_color
41
+ sub = sub.with_flag('-force') if force
42
+ sub
43
+ end
44
+ .with_argument(directory)
45
45
  end
46
46
  end
47
47
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lino'
4
3
  require_relative 'base'
5
4
 
6
5
  module RubyTerraform
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -6,13 +5,13 @@ module RubyTerraform
6
5
  class Get < Base
7
6
  def configure_command(builder, opts)
8
7
  builder
9
- .with_subcommand('get') do |sub|
10
- sub = sub.with_option('-update', true) if opts[:update]
11
- sub = sub.with_flag('-no-color') if opts[:no_color]
12
- sub
13
- end
14
- .with_argument(opts[:directory])
8
+ .with_subcommand('get') do |sub|
9
+ sub = sub.with_option('-update', true) if opts[:update]
10
+ sub = sub.with_flag('-no-color') if opts[:no_color]
11
+ sub
12
+ end
13
+ .with_argument(opts[:directory])
15
14
  end
16
15
  end
17
16
  end
18
- end
17
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lino'
3
+ require 'json'
4
4
  require_relative 'base'
5
5
 
6
6
  module RubyTerraform
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -15,21 +14,28 @@ module RubyTerraform
15
14
  force_copy = opts[:force_copy]
16
15
 
17
16
  builder = builder
18
- .with_subcommand('init') do |sub|
19
- sub = sub.with_option('-backend', backend) unless backend.nil?
20
- sub = sub.with_option('-force-copy', force_copy) unless force_copy.nil?
21
- sub = sub.with_option('-get', get) unless get.nil?
22
- sub = sub.with_option('-from-module', source) if source
23
- sub = sub.with_flag('-no-color') if no_color
24
- sub = sub.with_option('-plugin-dir', plugin_dir) unless plugin_dir.nil?
25
- backend_config.each do |key, value|
26
- sub = sub.with_option(
27
- '-backend-config',
28
- "'#{key}=#{value}'",
29
- separator: ' ')
30
- end
31
- sub
32
- end
17
+ .with_subcommand('init') do |sub|
18
+ sub = sub.with_option('-backend', backend) unless backend.nil?
19
+ unless force_copy.nil?
20
+ sub = sub.with_option('-force-copy',
21
+ force_copy)
22
+ end
23
+ sub = sub.with_option('-get', get) unless get.nil?
24
+ sub = sub.with_option('-from-module', source) if source
25
+ sub = sub.with_flag('-no-color') if no_color
26
+ unless plugin_dir.nil?
27
+ sub = sub.with_option('-plugin-dir',
28
+ plugin_dir)
29
+ end
30
+ backend_config.each do |key, value|
31
+ sub = sub.with_option(
32
+ '-backend-config',
33
+ "'#{key}=#{value}'",
34
+ separator: ' '
35
+ )
36
+ end
37
+ sub
38
+ end
33
39
 
34
40
  builder = builder.with_argument(path) if path
35
41
 
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require 'stringio'
3
2
  require_relative 'base'
4
3
 
@@ -19,7 +18,7 @@ module RubyTerraform
19
18
  mod = opts[:module]
20
19
 
21
20
  builder = builder
22
- .with_subcommand('output') do |sub|
21
+ .with_subcommand('output') do |sub|
23
22
  sub = sub.with_flag('-no-color') if no_color
24
23
  sub = sub.with_flag('-json') if json
25
24
  sub = sub.with_option('-state', state) if state
@@ -1,4 +1,4 @@
1
- require 'lino'
1
+ require 'json'
2
2
  require_relative 'base'
3
3
 
4
4
  module RubyTerraform
@@ -18,28 +18,29 @@ module RubyTerraform
18
18
  no_color = opts[:no_color]
19
19
 
20
20
  builder
21
- .with_subcommand('plan') do |sub|
22
- vars.each do |key, value|
23
- var_value = value.is_a?(String) ? value : JSON.generate(value)
24
- sub = sub.with_option(
25
- '-var', "'#{key}=#{var_value}'", separator: ' ')
26
- end
27
- sub = sub.with_option('-var-file', var_file) if var_file
28
- var_files.each do |file|
29
- sub = sub.with_option('-var-file', file)
30
- end
31
- sub = sub.with_option('-target', target) if target
32
- targets.each do |file|
33
- sub = sub.with_option('-target', file)
34
- end
35
- sub = sub.with_option('-state', state) if state
36
- sub = sub.with_option('-out', plan) if plan
37
- sub = sub.with_option('-input', input) if input
38
- sub = sub.with_flag('-destroy') if destroy
39
- sub = sub.with_flag('-no-color') if no_color
40
- sub
41
- end
42
- .with_argument(directory)
21
+ .with_subcommand('plan') do |sub|
22
+ vars.each do |key, value|
23
+ var_value = value.is_a?(String) ? value : JSON.generate(value)
24
+ sub = sub.with_option(
25
+ '-var', "'#{key}=#{var_value}'", separator: ' '
26
+ )
27
+ end
28
+ sub = sub.with_option('-var-file', var_file) if var_file
29
+ var_files.each do |file|
30
+ sub = sub.with_option('-var-file', file)
31
+ end
32
+ sub = sub.with_option('-target', target) if target
33
+ targets.each do |file|
34
+ sub = sub.with_option('-target', file)
35
+ end
36
+ sub = sub.with_option('-state', state) if state
37
+ sub = sub.with_option('-out', plan) if plan
38
+ sub = sub.with_option('-input', input) if input
39
+ sub = sub.with_flag('-destroy') if destroy
40
+ sub = sub.with_flag('-no-color') if no_color
41
+ sub
42
+ end
43
+ .with_argument(directory)
43
44
  end
44
45
  end
45
46
  end
@@ -1,4 +1,4 @@
1
- require 'lino'
1
+ require 'json'
2
2
  require_relative 'base'
3
3
 
4
4
  module RubyTerraform
@@ -16,26 +16,27 @@ module RubyTerraform
16
16
  no_color = opts[:no_color]
17
17
 
18
18
  builder
19
- .with_subcommand('refresh') do |sub|
20
- vars.each do |key, value|
21
- var_value = value.is_a?(String) ? value : JSON.generate(value)
22
- sub = sub.with_option(
23
- '-var', "'#{key}=#{var_value}'", separator: ' ')
24
- end
25
- sub = sub.with_option('-var-file', var_file) if var_file
26
- var_files.each do |file|
27
- sub = sub.with_option('-var-file', file)
28
- end
29
- sub = sub.with_option('-state', state) if state
30
- sub = sub.with_option('-input', input) if input
31
- sub = sub.with_option('-target', target) if target
32
- targets.each do |target_name|
33
- sub = sub.with_option('-target', target_name)
34
- end
35
- sub = sub.with_flag('-no-color') if no_color
36
- sub
37
- end
38
- .with_argument(directory)
19
+ .with_subcommand('refresh') do |sub|
20
+ vars.each do |key, value|
21
+ var_value = value.is_a?(String) ? value : JSON.generate(value)
22
+ sub = sub.with_option(
23
+ '-var', "'#{key}=#{var_value}'", separator: ' '
24
+ )
25
+ end
26
+ sub = sub.with_option('-var-file', var_file) if var_file
27
+ var_files.each do |file|
28
+ sub = sub.with_option('-var-file', file)
29
+ end
30
+ sub = sub.with_option('-state', state) if state
31
+ sub = sub.with_option('-input', input) if input
32
+ sub = sub.with_option('-target', target) if target
33
+ targets.each do |target_name|
34
+ sub = sub.with_option('-target', target_name)
35
+ end
36
+ sub = sub.with_flag('-no-color') if no_color
37
+ sub
38
+ end
39
+ .with_argument(directory)
39
40
  end
40
41
  end
41
42
  end
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -10,18 +9,19 @@ module RubyTerraform
10
9
  backend_config = opts[:backend_config] || {}
11
10
 
12
11
  builder
13
- .with_subcommand('remote')
14
- .with_subcommand('config') do |sub|
15
- sub = sub.with_option('-backend', backend) if backend
16
- backend_config.each do |key, value|
17
- sub = sub.with_option(
18
- '-backend-config', "'#{key}=#{value}'", separator: ' ')
19
- end
12
+ .with_subcommand('remote')
13
+ .with_subcommand('config') do |sub|
14
+ sub = sub.with_option('-backend', backend) if backend
15
+ backend_config.each do |key, value|
16
+ sub = sub.with_option(
17
+ '-backend-config', "'#{key}=#{value}'", separator: ' '
18
+ )
19
+ end
20
20
 
21
- sub = sub.with_flag('-no-color') if no_color
22
- sub
23
- end
21
+ sub = sub.with_flag('-no-color') if no_color
22
+ sub
23
+ end
24
24
  end
25
25
  end
26
26
  end
27
- end
27
+ end