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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15814ddd80516c55b1b513bbacd254ff0fe65220fac48e0c070860731ec17a9b
4
- data.tar.gz: d961254ad57da11e228e93af7f92a743a1aa5799a33da5268701b1418ca4b83a
3
+ metadata.gz: 75556dce8a559e6ff860bf9f21ea1ed798b04399b53930ee1df6db65e2ba3ac2
4
+ data.tar.gz: 734b3a9d311a68b3258629c5575cb03c7d2cd4a2b8824f8ea640a718b03546f3
5
5
  SHA512:
6
- metadata.gz: 4cf3ec4306aa0cfb551525ea69e02f68735ab43b22826b778092b0682ff16f4383399c78a1c5f1c7e8cd3fce4e1acd9db712b99186392ab1fd33907fe85c32b7
7
- data.tar.gz: b68c324cbbb60630b65c2bfbef753f42d23109294684b83dbfddd8fb4dc79a354c98063588a8398d18cf124a7158ddf04fa7d2f376a00efd4a2e394eeb2ee2dc
6
+ metadata.gz: 5071f1b85706c3322ae793f0ead129c3f43a804c24ae12b3d45e6742ed950e97a0995edf50fcb92c90d1af95a0d45fb2382b3444d3b5ef3acf0fbeeef9c74dcf
7
+ data.tar.gz: 21551855b1c15fa1b4485a3770f655e690f891eaa4c0ebf6cdd4b5884a4d1d8545cabe196e9db8622112ad772400191d53064abd647919313787a8206f9b2e87
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.39.0.pre.pre.1)
4
+ ruby-terraform (0.39.0.pre.pre.2)
5
5
  lino (~> 1.1)
6
6
 
7
7
  GEM
@@ -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
- attr_reader :binary
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
- .build
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
- stdin: stdin,
38
- stdout: stdout,
39
- stderr: stderr
24
+ stdin: stdin,
25
+ stdout: stdout,
26
+ stderr: stderr
40
27
  )
41
28
  do_after(opts)
42
29
  rescue Open4::SpawnError
43
- @logger.error "Terraform has failed while running '#{command_name}'."
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
- @logger.info "Cleaning terraform directory '#{directory}'."
14
- FileUtils.rm_r(directory, :secure => true)
15
- rescue Errno::ENOENT => e
16
- @logger.error "Couldn't clean '#{directory}': #{e.message}"
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 stdout
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
- sub = sub.with_flag('-no-color') if no_color
22
- sub = sub.with_option('-state', state) if state
23
- sub = sub.with_option('-module', mod) if mod
24
- sub
25
- end
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 = @stdout.string
32
+ result = stdout.string
32
33
  opts[:name] ? result.chomp : result
33
34
  end
34
35
  end
@@ -14,4 +14,4 @@ require_relative 'commands/workspace'
14
14
  module RubyTerraform
15
15
  module Commands
16
16
  end
17
- end
17
+ end
@@ -0,0 +1,6 @@
1
+ module RubyTerraform
2
+ module Errors
3
+ class ExecutionError < StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'errors/execution_error'
2
+
3
+ module RubyTerraform
4
+ module Errors
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyTerraform
2
- VERSION = "0.39.0-pre.1"
2
+ VERSION = "0.39.0-pre.2"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'ruby_terraform/version'
2
+ require 'ruby_terraform/errors'
2
3
  require 'ruby_terraform/commands'
3
4
  require 'logger'
4
5
 
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.1
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-04 00:00:00.000000000 Z
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