terraform_landscape 0.2.2 → 0.3.0

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: 98a71818264c2488766b447e16abbd2be9eb743ddd8faf717df0b0652742ea36
4
- data.tar.gz: 883c3799319b75efb960a6e185897a581d2362e4499c0f442dcf155669221d04
3
+ metadata.gz: 7eb8ec1bcf22cf01150a1934248b46c2e0603bc16bdb1ac0cbfd32a8ef8a54d4
4
+ data.tar.gz: 23f41d4a701ae0aa315352976cabb088cd05efa83e0c9e7b07ab56b5713bd09e
5
5
  SHA512:
6
- metadata.gz: d49d670112420768a487c6f69a009923a75607d8cfcc58beffa8824c96aec6ddd931a8c71b2281a69ea300558be4b05ce2058fb57b0ac1df101dac3e7fee0104
7
- data.tar.gz: 42b90645cf8ab30928c2257afc11ebf943afe1216e9983f14c652808e8d22cd0a7b3cc9e988fa384b0158003696ed60b985b0b18959b7c2b80ff99497b574382
6
+ metadata.gz: ce15fc65aecbcca148c1c0fa773dd5e8ab4b13ec4305b5c7b7b921f2f7e4dbfd380ef61642c2734dd1fcfa22deae637e6bac578254d0182186b90d106e714829
7
+ data.tar.gz: f433aef801d0e0d02d8669075785f3817a5bf3febf6c4a26235c79e989953cc1a4981dc8a83584f3855089f5d08cde567f2f70b3fddd1c221684c3c94a0cb15f
@@ -30,9 +30,14 @@ module TerraformLandscape
30
30
 
31
31
  def define_commands
32
32
  command :print do |c|
33
- c.action do
34
- print
33
+ c.action do |_args, options|
34
+ print(options.__hash__)
35
35
  end
36
+ c.description = <<-TXT
37
+ Pretty-prints your Terraform plan output.
38
+
39
+ If an error occurs while parsing the Terraform output, print will automatically fall back on the original Terraform output. To view the stack trace instead, provide the global --trace option.
40
+ TXT
36
41
  end
37
42
 
38
43
  global_option '--no-color', 'Do not output any color' do
@@ -43,9 +48,9 @@ module TerraformLandscape
43
48
  default_command :print
44
49
  end
45
50
 
46
- def print
51
+ def print(options)
47
52
  printer = Printer.new(@output)
48
- printer.process_stream(STDIN)
53
+ printer.process_stream(STDIN, options)
49
54
  end
50
55
  end
51
56
  end
@@ -6,4 +6,7 @@ module TerraformLandscape
6
6
 
7
7
  REPO_URL = 'https://github.com/coinbase/terraform_landscape'.freeze
8
8
  BUG_REPORT_URL = "#{REPO_URL}/issues".freeze
9
+
10
+ FALLBACK_MESSAGE = 'Terraform Landscape: a parsing error occured.' \
11
+ ' Falling back to original Terraform output...'.freeze
9
12
  end
@@ -8,9 +8,10 @@ module TerraformLandscape
8
8
  @output = output
9
9
  end
10
10
 
11
- def process_stream(io) # rubocop:disable Metrics/MethodLength
11
+ def process_stream(io, options = {}) # rubocop:disable Metrics/MethodLength
12
12
  apply = nil
13
13
  buffer = StringIO.new
14
+ original_tf_output = StringIO.new
14
15
  begin
15
16
  block_size = 1024
16
17
 
@@ -21,7 +22,9 @@ module TerraformLandscape
21
22
 
22
23
  readable_fds.each do |f|
23
24
  begin
24
- buffer << strip_ansi(f.read_nonblock(block_size))
25
+ new_output = f.read_nonblock(block_size)
26
+ original_tf_output << new_output
27
+ buffer << strip_ansi(new_output)
25
28
  rescue IO::WaitReadable # rubocop:disable Lint/HandleExceptions
26
29
  # Ignore; we'll call IO.select again
27
30
  rescue EOFError
@@ -34,9 +37,17 @@ module TerraformLandscape
34
37
  replace: ''))
35
38
  done = true if apply
36
39
  end
37
- process_string(buffer.string)
38
40
 
39
- @output.print apply if apply
41
+ begin
42
+ process_string(buffer.string)
43
+ @output.print apply if apply
44
+ rescue ParseError, TerraformPlan::ParseError => e
45
+ raise e if options[:trace]
46
+
47
+ @output.warning FALLBACK_MESSAGE
48
+ @output.print original_tf_output.string
49
+ end
50
+
40
51
  @output.write_from(io)
41
52
  ensure
42
53
  io.close
@@ -2,7 +2,6 @@ require 'colorize'
2
2
  require 'diffy'
3
3
  require 'json'
4
4
  require 'treetop'
5
- require 'string_undump'
6
5
 
7
6
  ########################################################################
8
7
  # Represents the parsed output of `terraform plan`.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module TerraformLandscape
5
- VERSION = '0.2.2'.freeze
5
+ VERSION = '0.3.0'.freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform_landscape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coinbase
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-30 00:00:00.000000000 Z
12
+ date: 2019-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -53,20 +53,6 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.0'
56
- - !ruby/object:Gem::Dependency
57
- name: string_undump
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: 0.1.1
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: 0.1.1
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: treetop
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -112,15 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
98
  requirements:
113
99
  - - ">="
114
100
  - !ruby/object:Gem::Version
115
- version: '2'
101
+ version: '2.5'
116
102
  required_rubygems_version: !ruby/object:Gem::Requirement
117
103
  requirements:
118
104
  - - ">="
119
105
  - !ruby/object:Gem::Version
120
106
  version: '0'
121
107
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.7.7
108
+ rubygems_version: 3.0.1
124
109
  signing_key:
125
110
  specification_version: 4
126
111
  summary: Pretty-print Terraform plan output