rspec-terraform 0.1.0.pre.20 → 0.1.0.pre.21

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: c33bac6bc11ec62bb0dd06035958076661a9ba193446ddad9c9299c7fc7c1c87
4
- data.tar.gz: f03c579d40424f7b3eeb1d11b2f354e5709148ab71b491702e0c5dd5277893fb
3
+ metadata.gz: d3a1d7d419c7e13ea95d8cf7b04ffe5183aa1cfce3d48e3027609b061416e640
4
+ data.tar.gz: 1f33098b03b9cba5294b2894f691d55d26f666185d1d6e9a748345a0fc383080
5
5
  SHA512:
6
- metadata.gz: f75e6299fa46e44d2ff7c525529495e492346d88c8ae0a9634395d4a623871496487b517710177151e9ae871843506d41be8b57581e67785bdaf9f0efe11cf32
7
- data.tar.gz: 9f44c320439d80991c33e86f075fa4012e88c31cec8c66caaeba2486cf03785a272363e7141ab5a1949ee26837bb41e97db1a93e914e99335399879e20344d85
6
+ metadata.gz: f3dedee60ba29285bc292f263791cd117cff0adff0b092042f6774d321a9eba268431d601ce2cf7d39688c50777c342cde6ab4b20f6ac5603ad7eb3bbe665afa
7
+ data.tar.gz: 52fe2ac848e6e1d0d5e4677731dcd51db1483d2119966157d7d854ab73f1d2acd676f5412c4bb051ab740d77e9927c3d3e5bbf14bd756dc331853e1a93b13e09
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.20)
4
+ rspec-terraform (0.1.0.pre.21)
5
5
  rspec (>= 3.0)
6
6
  ruby-terraform (= 1.7.0.pre.13)
7
7
 
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Terraform
5
+ module Configuration
6
+ class Merger
7
+ def merge(left, right)
8
+ merge_top_level(left, right)
9
+ .merge(merge_accumulating_maps(left, right))
10
+ .merge(merge_accumulating_lists(left, right))
11
+ end
12
+
13
+ private
14
+
15
+ def merge_top_level(left, right)
16
+ left.merge(right)
17
+ end
18
+
19
+ def merge_accumulating_maps(left, right)
20
+ left_vars = left[:vars] || {}
21
+ right_vars = right[:vars] || {}
22
+ vars = left_vars.merge(right_vars)
23
+
24
+ merged = {}
25
+ unless left_vars == {} && right_vars == {}
26
+ merged = merged.merge(vars: vars)
27
+ end
28
+
29
+ merged
30
+ end
31
+
32
+ def merge_accumulating_lists(left, right)
33
+ left_var_files = left[:var_files] || []
34
+ right_var_files = right[:var_files] || []
35
+ var_files = left_var_files + right_var_files
36
+
37
+ merged = {}
38
+ unless left_var_files == [] && right_var_files == []
39
+ merged = merged.merge(var_files: var_files)
40
+ end
41
+
42
+ merged
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -7,7 +7,7 @@ module RSpec
7
7
  module Configuration
8
8
  module Providers
9
9
  class Identity
10
- def resolve(overrides)
10
+ def resolve(overrides = {})
11
11
  overrides
12
12
  end
13
13
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ruby_terraform'
4
+ require_relative '../merger'
4
5
 
5
6
  module RSpec
6
7
  module Terraform
@@ -11,20 +12,11 @@ module RSpec
11
12
 
12
13
  def initialize(configuration = {})
13
14
  @configuration = configuration
15
+ @merger = Merger.new
14
16
  end
15
17
 
16
18
  def resolve(overrides = {})
17
- left_vars = configuration[:vars] || {}
18
- right_vars = overrides[:vars] || {}
19
- vars = left_vars.merge(right_vars)
20
-
21
- top_level_merge = configuration.merge(overrides)
22
-
23
- if left_vars == {} && right_vars == {}
24
- top_level_merge
25
- else
26
- top_level_merge.merge(vars: vars)
27
- end
19
+ @merger.merge(configuration, overrides)
28
20
  end
29
21
  end
30
22
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'configuration/providers'
4
+ require_relative 'configuration/merger'
4
5
 
5
6
  module RSpec
6
7
  module Terraform
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.20'
5
+ VERSION = '0.1.0.pre.21'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.20
4
+ version: 0.1.0.pre.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
@@ -280,6 +280,7 @@ files:
280
280
  - bin/setup
281
281
  - lib/rspec/terraform.rb
282
282
  - lib/rspec/terraform/configuration.rb
283
+ - lib/rspec/terraform/configuration/merger.rb
283
284
  - lib/rspec/terraform/configuration/providers.rb
284
285
  - lib/rspec/terraform/configuration/providers/identity.rb
285
286
  - lib/rspec/terraform/configuration/providers/in_memory.rb