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.
- checksums.yaml +4 -4
- data/Gemfile.lock +111 -32
- data/README.md +29 -9
- data/Rakefile +81 -37
- data/bin/console +3 -3
- data/lib/ruby-terraform.rb +1 -1
- data/lib/ruby_terraform.rb +1 -1
- data/lib/ruby_terraform/commands/apply.rb +24 -24
- data/lib/ruby_terraform/commands/base.rb +12 -14
- data/lib/ruby_terraform/commands/clean.rb +2 -2
- data/lib/ruby_terraform/commands/destroy.rb +24 -24
- data/lib/ruby_terraform/commands/format.rb +0 -1
- data/lib/ruby_terraform/commands/get.rb +7 -8
- data/lib/ruby_terraform/commands/import.rb +1 -1
- data/lib/ruby_terraform/commands/init.rb +22 -16
- data/lib/ruby_terraform/commands/output.rb +1 -2
- data/lib/ruby_terraform/commands/plan.rb +24 -23
- data/lib/ruby_terraform/commands/refresh.rb +22 -21
- data/lib/ruby_terraform/commands/remote_config.rb +12 -12
- data/lib/ruby_terraform/commands/show.rb +0 -1
- data/lib/ruby_terraform/commands/validate.rb +20 -19
- data/lib/ruby_terraform/commands/workspace.rb +4 -7
- data/lib/ruby_terraform/errors/execution_error.rb +1 -1
- data/lib/ruby_terraform/version.rb +1 -1
- metadata +111 -43
- data/.circleci/config.yml +0 -56
- data/.circleci/gpg.private.enc +0 -0
- data/.envrc +0 -5
- data/.git-crypt/.gitattributes +0 -4
- data/.git-crypt/keys/default/0/41D2606F66C3FF28874362B61A16916844CE9D82.gpg +0 -0
- data/.git-crypt/keys/default/0/AAE932B730C2BA697FFDFAE05DA390873E38358B.gpg +0 -0
- data/.gitattributes +0 -1
- data/.gitignore +0 -31
- data/.rspec +0 -2
- data/.ruby-version +0 -1
- data/CHANGELOG.md +0 -44
- data/TODO.md +0 -1
- data/config/secrets/.unlocked +0 -1
- data/config/secrets/ci/encryption.passphrase +0 -1
- data/config/secrets/ci/gpg.private +0 -58
- data/config/secrets/ci/gpg.public +0 -31
- data/config/secrets/ci/ssh.private +0 -51
- data/config/secrets/ci/ssh.public +0 -1
- data/config/secrets/circle_ci/config.yaml +0 -2
- data/config/secrets/github/config.yaml +0 -2
- data/config/secrets/rubygems/credentials +0 -2
- data/go +0 -56
- data/ruby_terraform.gemspec +0 -37
- data/scripts/ci/common/configure-git.sh +0 -8
- data/scripts/ci/common/configure-rubygems.sh +0 -16
- data/scripts/ci/common/install-git-crypt.sh +0 -8
- data/scripts/ci/common/install-gpg-key.sh +0 -19
- data/scripts/ci/steps/prerelease.sh +0 -16
- data/scripts/ci/steps/release.sh +0 -18
- data/scripts/ci/steps/test.sh +0 -12
data/lib/ruby-terraform.rb
CHANGED
data/lib/ruby_terraform.rb
CHANGED
@@ -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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
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
|
22
|
+
logger.debug("Running '#{command}'.")
|
22
23
|
|
23
24
|
command.execute(
|
24
|
-
|
25
|
-
|
26
|
-
|
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(
|
41
|
+
self.class.to_s.split('::')[-1].downcase
|
41
42
|
end
|
42
43
|
|
43
44
|
def instantiate_builder
|
44
45
|
Lino::CommandLineBuilder
|
45
|
-
|
46
|
-
|
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
|
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, :
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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,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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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,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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
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 '
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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 '
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
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
|