ruby-terraform 0.39.0.pre.pre.1 → 0.39.0.pre.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ruby_terraform/commands/base.rb +19 -27
- data/lib/ruby_terraform/commands/clean.rb +8 -4
- data/lib/ruby_terraform/commands/output.rb +8 -7
- data/lib/ruby_terraform/commands.rb +1 -1
- data/lib/ruby_terraform/errors/execution_error.rb +6 -0
- data/lib/ruby_terraform/errors.rb +6 -0
- data/lib/ruby_terraform/version.rb +1 -1
- data/lib/ruby_terraform.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75556dce8a559e6ff860bf9f21ea1ed798b04399b53930ee1df6db65e2ba3ac2
|
4
|
+
data.tar.gz: 734b3a9d311a68b3258629c5575cb03c7d2cd4a2b8824f8ea640a718b03546f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5071f1b85706c3322ae793f0ead129c3f43a804c24ae12b3d45e6742ed950e97a0995edf50fcb92c90d1af95a0d45fb2382b3444d3b5ef3acf0fbeeef9c74dcf
|
7
|
+
data.tar.gz: 21551855b1c15fa1b4485a3770f655e690f891eaa4c0ebf6cdd4b5884a4d1d8545cabe196e9db8622112ad772400191d53064abd647919313787a8206f9b2e87
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'lino'
|
2
|
+
require_relative '../errors'
|
2
3
|
|
3
4
|
module RubyTerraform
|
4
5
|
module Commands
|
5
6
|
class Base
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(binary: nil, logger: nil, stdin: nil, stdout: nil, stderr: nil)
|
7
|
+
def initialize(
|
8
|
+
binary: nil, logger: nil, stdin: nil, stdout: nil, stderr: nil)
|
9
9
|
@binary = binary || RubyTerraform.configuration.binary
|
10
10
|
@logger = logger || RubyTerraform.configuration.logger
|
11
11
|
@stdin = stdin || RubyTerraform.configuration.stdin
|
@@ -13,34 +13,31 @@ module RubyTerraform
|
|
13
13
|
@stderr = stderr || RubyTerraform.configuration.stderr
|
14
14
|
end
|
15
15
|
|
16
|
-
def stdin
|
17
|
-
@stdin
|
18
|
-
end
|
19
|
-
|
20
|
-
def stdout
|
21
|
-
@stdout
|
22
|
-
end
|
23
|
-
|
24
|
-
def stderr
|
25
|
-
@stderr
|
26
|
-
end
|
27
|
-
|
28
16
|
def execute(opts = {})
|
29
17
|
builder = instantiate_builder
|
30
18
|
|
31
19
|
do_before(opts)
|
32
|
-
command = configure_command(builder, opts)
|
33
|
-
|
34
|
-
@logger.debug "Running '#{command.to_s}'."
|
20
|
+
command = configure_command(builder, opts).build
|
21
|
+
logger.debug("Running '#{command.to_s}'.")
|
35
22
|
|
36
23
|
command.execute(
|
37
|
-
|
38
|
-
|
39
|
-
|
24
|
+
stdin: stdin,
|
25
|
+
stdout: stdout,
|
26
|
+
stderr: stderr
|
40
27
|
)
|
41
28
|
do_after(opts)
|
42
29
|
rescue Open4::SpawnError
|
43
|
-
|
30
|
+
message = "Failed while running '#{command_name}'."
|
31
|
+
logger.error(message)
|
32
|
+
raise Errors::ExecutionError, message
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
attr_reader :binary, :logger, :stdin, :stdout, :stderr
|
38
|
+
|
39
|
+
def command_name
|
40
|
+
self.class.to_s.split("::")[-1].downcase
|
44
41
|
end
|
45
42
|
|
46
43
|
def instantiate_builder
|
@@ -57,11 +54,6 @@ module RubyTerraform
|
|
57
54
|
|
58
55
|
def do_after(opts)
|
59
56
|
end
|
60
|
-
|
61
|
-
def command_name
|
62
|
-
self.class.to_s.split("::")[-1].downcase
|
63
|
-
end
|
64
|
-
protected :command_name
|
65
57
|
end
|
66
58
|
end
|
67
59
|
end
|
@@ -3,6 +3,8 @@ require 'fileutils'
|
|
3
3
|
module RubyTerraform
|
4
4
|
module Commands
|
5
5
|
class Clean
|
6
|
+
attr_reader :logger
|
7
|
+
|
6
8
|
def initialize(directory: nil, logger: nil)
|
7
9
|
@directory = directory ? directory : '.terraform'
|
8
10
|
@logger = logger || RubyTerraform.configuration.logger
|
@@ -10,10 +12,12 @@ module RubyTerraform
|
|
10
12
|
|
11
13
|
def execute(opts = {})
|
12
14
|
directory = opts[:directory] || @directory
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
begin
|
16
|
+
logger.info "Cleaning terraform directory '#{directory}'."
|
17
|
+
FileUtils.rm_r(directory, :secure => true)
|
18
|
+
rescue Errno::ENOENT => e
|
19
|
+
logger.error "Couldn't clean '#{directory}': #{e.message}"
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -5,7 +5,8 @@ require_relative 'base'
|
|
5
5
|
module RubyTerraform
|
6
6
|
module Commands
|
7
7
|
class Output < Base
|
8
|
-
def
|
8
|
+
def initialize(**kwargs)
|
9
|
+
super(**kwargs)
|
9
10
|
@stdout = StringIO.new unless
|
10
11
|
defined?(@stdout) && @stdout.respond_to?(:string)
|
11
12
|
end
|
@@ -18,17 +19,17 @@ module RubyTerraform
|
|
18
19
|
|
19
20
|
builder = builder
|
20
21
|
.with_subcommand('output') do |sub|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
sub = sub.with_flag('-no-color') if no_color
|
23
|
+
sub = sub.with_option('-state', state) if state
|
24
|
+
sub = sub.with_option('-module', mod) if mod
|
25
|
+
sub
|
26
|
+
end
|
26
27
|
builder = builder.with_argument(name) if name
|
27
28
|
builder
|
28
29
|
end
|
29
30
|
|
30
31
|
def do_after(opts)
|
31
|
-
result =
|
32
|
+
result = stdout.string
|
32
33
|
opts[:name] ? result.chomp : result
|
33
34
|
end
|
34
35
|
end
|
data/lib/ruby_terraform.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-terraform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.39.0.pre.pre.
|
4
|
+
version: 0.39.0.pre.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Clemson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lino
|
@@ -131,6 +131,8 @@ files:
|
|
131
131
|
- lib/ruby_terraform/commands/show.rb
|
132
132
|
- lib/ruby_terraform/commands/validate.rb
|
133
133
|
- lib/ruby_terraform/commands/workspace.rb
|
134
|
+
- lib/ruby_terraform/errors.rb
|
135
|
+
- lib/ruby_terraform/errors/execution_error.rb
|
134
136
|
- lib/ruby_terraform/version.rb
|
135
137
|
- ruby_terraform.gemspec
|
136
138
|
- scripts/ci/common/configure-git.sh
|