ruby-terraform 1.7.0.pre.4 → 1.7.0.pre.7

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: e7e33039e6162acf99865f3e33e3208d288bc93b7c1a43d39c3b44f137bdcf92
4
- data.tar.gz: 7e7ef758f7bb5bdbeabbda16019c49afe3305aaba9089787d4681f3e875a2f3c
3
+ metadata.gz: 40166cca660dc61e95b7b9983f757c4e3c148005226006167adebea38c5922bb
4
+ data.tar.gz: 8140497c2e9c0a7acb5bce2967157a47b796bb2e0c716b70477cfac936a55fbd
5
5
  SHA512:
6
- metadata.gz: 80ab103749e2a57d90d339b83171f2e56128523aea06cfb2643b6e5c30d5bddb340734e3b3ca0248188217807b284c6c47c922fba7de6ec507d4771f90e2c659
7
- data.tar.gz: 0b70beb4a0efd237b1aab284068eaaa244c45c62050b115fdc8e793f6347ab7b85b8adc8e824569fcd09e08fc055842e27a1bfa8456efe5723c1bf9aacdd61f7
6
+ metadata.gz: a6d0e5d37e4a84ed32d97e12af6af490cbfd9d08323cc811e58dcdd7595f6aed067c9f7348a2da1ce591e7c00556c305df3e4492a8644006be864b54f1d8f475
7
+ data.tar.gz: ff0ba6c53a93af497e79ec00a75f25baa2667ed86009a475d976ecf15b949c8eded5fde7a4e69b5ae1b7f0c6126df979d945a6b7165cfe479498c2f584171668
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (1.7.0.pre.4)
4
+ ruby-terraform (1.7.0.pre.7)
5
5
  immutable-struct (~> 2.4)
6
6
  lino (~> 3.0)
7
7
 
data/Rakefile CHANGED
@@ -58,7 +58,7 @@ namespace :library do
58
58
  task check: [:rubocop]
59
59
 
60
60
  desc 'Attempt to automatically fix issues with the library'
61
- task fix: [:'rubocop:autocorrect']
61
+ task fix: [:'rubocop:autocorrect_all']
62
62
  end
63
63
 
64
64
  namespace :documentation do
@@ -23,6 +23,10 @@ module RubyTerraform
23
23
  @sensitive
24
24
  end
25
25
 
26
+ def render(**_)
27
+ @value.nil? ? 'null' : @value.inspect
28
+ end
29
+
26
30
  def state
27
31
  [@value, @sensitive]
28
32
  end
@@ -51,6 +51,19 @@ module RubyTerraform
51
51
  @sensitive
52
52
  end
53
53
 
54
+ def render(level: 0, indent: ' ')
55
+ return '[]' if empty?
56
+
57
+ opts = { level: level + 1, indent: indent }
58
+ extra = level.times.collect { |_| indent }.join
59
+ lines =
60
+ value
61
+ .collect { |i| "#{extra}#{indent}#{i.render(opts)}" }
62
+ .join(",\n")
63
+
64
+ "[\n#{lines}\n#{extra}]"
65
+ end
66
+
54
67
  def state
55
68
  [@value, @sensitive]
56
69
  end
@@ -59,6 +72,7 @@ module RubyTerraform
59
72
  sensitive = sensitive? ? 'sensitive' : 'non-sensitive'
60
73
  "#{value.inspect} (#{sensitive})"
61
74
  end
75
+
62
76
  alias to_s inspect
63
77
  end
64
78
  end
@@ -29,7 +29,7 @@ module RubyTerraform
29
29
  )
30
30
 
31
31
  def initialize(value, sensitive: false)
32
- @value = value
32
+ @value = value.transform_keys(&:to_sym)
33
33
  @sensitive = sensitive
34
34
  end
35
35
 
@@ -47,6 +47,21 @@ module RubyTerraform
47
47
  @sensitive
48
48
  end
49
49
 
50
+ def render(bare: false, level: 0, indent: ' ')
51
+ return '{}' if empty?
52
+
53
+ next_level = bare ? level : level + 1
54
+ self_indent = bare ? '' : indent
55
+ opts = { level: next_level, indent: indent }
56
+ extra = level.times.collect { |_| indent }.join
57
+ lines =
58
+ value
59
+ .collect { |k, v| "#{extra}#{self_indent}#{k} = #{v.render(opts)}" }
60
+ .join("\n")
61
+
62
+ bare ? lines : "{\n#{lines}\n#{extra}}"
63
+ end
64
+
50
65
  def state
51
66
  [@value, @sensitive]
52
67
  end
@@ -10,8 +10,9 @@ module RubyTerraform
10
10
  # rubocop:disable Style/RedundantAssignment
11
11
  def box(object, unknown: nil, sensitive: nil)
12
12
  initial = boxed_empty_by_value(object)
13
- unknown ||= native_empty_by_value(object)
14
- sensitive ||= native_empty_by_value(object)
13
+ object = symbolise(object)
14
+ unknown = symbolised_or_native_empty(unknown, object)
15
+ sensitive = symbolised_or_native_empty(sensitive, object)
15
16
 
16
17
  return Values.unknown(sensitive: sensitive) if unknown == true
17
18
 
@@ -171,11 +172,26 @@ module RubyTerraform
171
172
  def normalise(object)
172
173
  case object
173
174
  when Array then object.each_with_index.to_a
174
- when Hash then object.to_a.map { |e| [e[1], e[0]] }
175
+ when Hash
176
+ object.to_a.map do |e|
177
+ [e[1], e[0].to_sym]
178
+ end
179
+ else object
180
+ end
181
+ end
182
+
183
+ def symbolise(object)
184
+ case object
185
+ when Hash
186
+ object.to_h { |key, value| [key.to_sym, symbolise(value)] }
175
187
  else object
176
188
  end
177
189
  end
178
190
 
191
+ def symbolised_or_native_empty(object, target)
192
+ object ? symbolise(object) : native_empty_by_value(target)
193
+ end
194
+
179
195
  def root_path(paths)
180
196
  paths.count == 1 && paths[0].empty?
181
197
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../value_equality'
4
+
5
+ module RubyTerraform
6
+ module Models
7
+ class OmittedValue
8
+ include ValueEquality
9
+
10
+ def initialize(sensitive: false)
11
+ @sensitive = sensitive
12
+ end
13
+
14
+ def value
15
+ nil
16
+ end
17
+ alias unbox value
18
+
19
+ def known?
20
+ false
21
+ end
22
+
23
+ def sensitive?
24
+ @sensitive
25
+ end
26
+
27
+ def render(**_)
28
+ '...'
29
+ end
30
+
31
+ def state
32
+ [@sensitive]
33
+ end
34
+
35
+ def inspect
36
+ sensitive = sensitive? ? 'sensitive' : 'non-sensitive'
37
+ "... (unknown, #{sensitive})"
38
+ end
39
+ end
40
+ end
41
+ end
@@ -24,6 +24,10 @@ module RubyTerraform
24
24
  @sensitive
25
25
  end
26
26
 
27
+ def render(**_)
28
+ '(known after apply)'
29
+ end
30
+
27
31
  def state
28
32
  [@sensitive]
29
33
  end
@@ -4,6 +4,7 @@ require_relative './list'
4
4
  require_relative './map'
5
5
  require_relative './known_value'
6
6
  require_relative './unknown_value'
7
+ require_relative './omitted_value'
7
8
 
8
9
  module RubyTerraform
9
10
  module Models
@@ -17,6 +18,10 @@ module RubyTerraform
17
18
  UnknownValue.new(sensitive: sensitive)
18
19
  end
19
20
 
21
+ def omitted(sensitive: false)
22
+ OmittedValue.new(sensitive: sensitive)
23
+ end
24
+
20
25
  def list(value, sensitive: false)
21
26
  List.new(value, sensitive: sensitive)
22
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyTerraform
4
- VERSION = '1.7.0.pre.4'
4
+ VERSION = '1.7.0.pre.7'
5
5
  end
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: 1.7.0.pre.4
4
+ version: 1.7.0.pre.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-17 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: immutable-struct
@@ -323,6 +323,7 @@ files:
323
323
  - lib/ruby_terraform/models/list.rb
324
324
  - lib/ruby_terraform/models/map.rb
325
325
  - lib/ruby_terraform/models/objects.rb
326
+ - lib/ruby_terraform/models/omitted_value.rb
326
327
  - lib/ruby_terraform/models/plan.rb
327
328
  - lib/ruby_terraform/models/resource_change.rb
328
329
  - lib/ruby_terraform/models/unknown_value.rb