rspec-terraform 0.1.0.pre.28 → 0.1.0.pre.31

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: 1c8f792e87abefbea94694f0fee81efbae81c54361681352b5f37860a8daad4e
4
- data.tar.gz: c95be85f8b07bde0d80fb42c0324b17a0a3973cfd51b29ad025bd377cb0470fe
3
+ metadata.gz: eaa5c41415be59f0dc571fa3f26d719ef78d5e18604688ade58770f39f3b124a
4
+ data.tar.gz: a27d2cef84a89423e11ddb46e117c9c37677ae54d1d23d28ba2f5d2ff5a2ac94
5
5
  SHA512:
6
- metadata.gz: d17f25036ba285de0d641952ad1ed0b04bf74cebb87d42125631a2eeb725f2a7da8606a156afe82aa695447c9ccb9ce1629cfde833a89cba8fb5c248690ab03b
7
- data.tar.gz: 750c207d47f2066f53f76ddc03d072d391163f7312ca83859c3880d9e12e7c0f36f8b28ce941256d8cdc06f5486d4e4fc9b0d56e6274f31f0d3c1013218b5d90
6
+ metadata.gz: 2306fb4b85b10fb4bbe7e2bf05e9782d0a9b7c08792597c14495d1efa1819af4188878621e988fd71d06d880f928280002922fb71669359135a8e84323918043
7
+ data.tar.gz: 408eff4057c23a6185aa34065ebc8f1c64aa309d2f574983a40020ec129b5747656ebf12bea469997139b7d6b37f7102d2a8ea20e17c28793f384ff2be3206e8
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.28)
4
+ rspec-terraform (0.1.0.pre.31)
5
+ confidante (>= 0.27)
5
6
  rspec (>= 3.0)
6
7
  ruby-terraform (= 1.7.0.pre.15)
7
8
 
@@ -19,8 +20,15 @@ GEM
19
20
  coderay (1.1.3)
20
21
  colored2 (3.1.2)
21
22
  concurrent-ruby (1.1.10)
23
+ confidante (0.27.0)
24
+ activesupport (>= 4)
25
+ hiera (~> 3.3, >= 3.3.1)
26
+ shikashi (~> 0.6)
22
27
  diff-lcs (1.5.0)
23
28
  docile (1.4.0)
29
+ evalhook (0.6.0)
30
+ partialruby (~> 0.3)
31
+ sexp_processor (~> 4.0)
24
32
  excon (0.92.4)
25
33
  faker (2.22.0)
26
34
  i18n (>= 1.8.11, < 2)
@@ -31,6 +39,7 @@ GEM
31
39
  ffi (1.15.5)
32
40
  formatador (1.1.0)
33
41
  gem-release (2.2.2)
42
+ getsource (0.2.2)
34
43
  guard (2.18.0)
35
44
  formatador (>= 0.2.4)
36
45
  listen (>= 2.7, < 4.0)
@@ -50,6 +59,7 @@ GEM
50
59
  rubocop (< 2.0)
51
60
  hamster (3.0.0)
52
61
  concurrent-ruby (~> 1.0)
62
+ hiera (3.10.0)
53
63
  i18n (1.12.0)
54
64
  concurrent-ruby (~> 1.0)
55
65
  immutable-struct (2.4.1)
@@ -74,6 +84,9 @@ GEM
74
84
  parallel (1.22.1)
75
85
  parser (3.1.2.1)
76
86
  ast (~> 2.4.1)
87
+ partialruby (0.3.0)
88
+ ruby2ruby (~> 2)
89
+ ruby_parser (~> 3)
77
90
  pry (0.14.1)
78
91
  coderay (~> 1.1)
79
92
  method_source (~> 1.0)
@@ -139,12 +152,21 @@ GEM
139
152
  immutable-struct (~> 2.4)
140
153
  lino (~> 3.0)
141
154
  ruby2_keywords (0.0.5)
155
+ ruby2ruby (2.4.4)
156
+ ruby_parser (~> 3.1)
157
+ sexp_processor (~> 4.6)
142
158
  ruby_gpg2 (0.8.0)
143
159
  lino (>= 1.5)
160
+ ruby_parser (3.19.1)
161
+ sexp_processor (~> 4.16)
144
162
  sawyer (0.9.2)
145
163
  addressable (>= 2.3.5)
146
164
  faraday (>= 0.17.3, < 3)
165
+ sexp_processor (4.16.1)
147
166
  shellany (0.0.1)
167
+ shikashi (0.6.0)
168
+ evalhook (>= 0.6.0)
169
+ getsource (>= 0.1.0)
148
170
  simplecov (0.21.2)
149
171
  docile (~> 1.1)
150
172
  simplecov-html (~> 0.11)
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ruby_terraform'
4
+
5
+ module RSpec
6
+ module Terraform
7
+ module Configuration
8
+ module Providers
9
+ class Base
10
+ def reset; end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'confidante'
4
+ require 'ruby_terraform'
5
+
6
+ require_relative './base'
7
+ require_relative '../merger'
8
+
9
+ module RSpec
10
+ module Terraform
11
+ module Configuration
12
+ module Providers
13
+ class Confidante < Base
14
+ attr_reader(
15
+ :parameters,
16
+ :scope_selector,
17
+ :overrides_selector,
18
+ :configuration,
19
+ :merger
20
+ )
21
+
22
+ def initialize(opts = {})
23
+ super()
24
+ @parameters = opts[:parameters] || []
25
+ @scope_selector = opts[:scope_selector] || ->(o) { o }
26
+ @overrides_selector = opts[:overrides_selector] || ->(o) { o }
27
+ @configuration = ::Confidante.configuration
28
+ @merger = opts[:merger] || Merger.new
29
+ end
30
+
31
+ def resolve(overrides = {})
32
+ resolved_configuration =
33
+ configuration
34
+ .for_scope(scope_selector.call(overrides))
35
+ .for_overrides(overrides_selector.call(overrides))
36
+ result = parameters.inject({}) do |acc, parameter|
37
+ value = resolved_configuration.send(parameter)
38
+ value.nil? ? acc : acc.merge(parameter => value)
39
+ end
40
+ merger.merge(result, overrides)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require 'ruby_terraform'
4
4
 
5
+ require_relative './base'
6
+
5
7
  module RSpec
6
8
  module Terraform
7
9
  module Configuration
8
10
  module Providers
9
- class Identity
11
+ class Identity < Base
10
12
  def resolve(overrides = {})
11
13
  overrides
12
14
  end
@@ -1,16 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ruby_terraform'
4
+
5
+ require_relative './base'
4
6
  require_relative '../merger'
5
7
 
6
8
  module RSpec
7
9
  module Terraform
8
10
  module Configuration
9
11
  module Providers
10
- class InMemory
12
+ class InMemory < Base
11
13
  attr_reader(:configuration)
12
14
 
13
15
  def initialize(configuration = {})
16
+ super()
14
17
  @configuration = configuration
15
18
  @merger = Merger.new
16
19
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ruby_terraform'
4
+ require 'securerandom'
5
+
6
+ require_relative './base'
7
+
8
+ module RSpec
9
+ module Terraform
10
+ module Configuration
11
+ module Providers
12
+ class Seed < Base
13
+ attr_reader(:generator, :merger)
14
+
15
+ def initialize(opts = {})
16
+ super()
17
+ @generator =
18
+ opts[:generator] || -> { SecureRandom.alphanumeric(10) }
19
+ @merger = opts[:merger] || Merger.new
20
+ end
21
+
22
+ def resolve(overrides = {})
23
+ merger.merge({ seed: seed }, overrides)
24
+ end
25
+
26
+ def reset
27
+ @seed = nil
28
+ end
29
+
30
+ private
31
+
32
+ def seed
33
+ @seed ||= generator.call
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require_relative 'providers/identity'
4
4
  require_relative 'providers/in_memory'
5
+ require_relative 'providers/confidante'
6
+ require_relative 'providers/seed'
5
7
 
6
8
  module RSpec
7
9
  module Terraform
@@ -12,8 +12,12 @@ module RSpec
12
12
  Providers::Identity.new
13
13
  end
14
14
 
15
- def in_memory_provider(overrides)
16
- Providers::InMemory.new(overrides)
15
+ def in_memory_provider(opts)
16
+ Providers::InMemory.new(opts)
17
+ end
18
+
19
+ def confidante_provider(opts)
20
+ Providers::Confidante.new(opts)
17
21
  end
18
22
  end
19
23
  end
@@ -9,18 +9,17 @@ module RSpec
9
9
  module Helpers
10
10
  class Apply
11
11
  attr_reader(
12
- :overrides, :configuration_provider, :binary, :execution_mode
12
+ :configuration_provider, :binary, :execution_mode
13
13
  )
14
14
 
15
- def initialize(overrides = {}, configuration_provider = nil)
16
- @overrides = overrides
15
+ def initialize(opts = {})
17
16
  @configuration_provider =
18
- configuration_provider || Configuration.identity_provider
17
+ opts[:configuration_provider] || Configuration.identity_provider
19
18
  @binary = RSpec.configuration.terraform_binary
20
19
  @execution_mode = RSpec.configuration.terraform_execution_mode
21
20
  end
22
21
 
23
- def execute(&block)
22
+ def execute(overrides = {}, &block)
24
23
  parameters = with_configuration_provider_parameters(overrides)
25
24
  parameters = with_resolved_vars(parameters, &block)
26
25
  parameters = with_mandatory_parameters(parameters)
@@ -9,18 +9,17 @@ module RSpec
9
9
  module Helpers
10
10
  class Destroy
11
11
  attr_reader(
12
- :overrides, :configuration_provider, :binary, :execution_mode
12
+ :configuration_provider, :binary, :execution_mode
13
13
  )
14
14
 
15
- def initialize(overrides = {}, configuration_provider = nil)
16
- @overrides = overrides
15
+ def initialize(opts = {})
17
16
  @configuration_provider =
18
- configuration_provider || Configuration.identity_provider
17
+ opts[:configuration_provider] || Configuration.identity_provider
19
18
  @binary = RSpec.configuration.terraform_binary
20
19
  @execution_mode = RSpec.configuration.terraform_execution_mode
21
20
  end
22
21
 
23
- def execute(&block)
22
+ def execute(overrides = {}, &block)
24
23
  parameters = with_configuration_provider_parameters(overrides)
25
24
  parameters = with_resolved_vars(parameters, &block)
26
25
 
@@ -7,18 +7,17 @@ module RSpec
7
7
  module Helpers
8
8
  class Output
9
9
  attr_reader(
10
- :overrides, :configuration_provider, :binary, :execution_mode
10
+ :configuration_provider, :binary, :execution_mode
11
11
  )
12
12
 
13
- def initialize(overrides = {}, configuration_provider = nil)
14
- @overrides = overrides
13
+ def initialize(opts = {})
15
14
  @configuration_provider =
16
- configuration_provider || Configuration.identity_provider
15
+ opts[:configuration_provider] || Configuration.identity_provider
17
16
  @binary = RSpec.configuration.terraform_binary
18
17
  @execution_mode = RSpec.configuration.terraform_execution_mode
19
18
  end
20
19
 
21
- def execute
20
+ def execute(overrides = {})
22
21
  parameters = with_configuration_provider_parameters(overrides)
23
22
  parameters = with_mandatory_parameters(parameters)
24
23
 
@@ -12,18 +12,17 @@ module RSpec
12
12
  # rubocop:disable Metrics/ClassLength
13
13
  class Plan
14
14
  attr_reader(
15
- :overrides, :configuration_provider, :binary, :execution_mode
15
+ :configuration_provider, :binary, :execution_mode
16
16
  )
17
17
 
18
- def initialize(overrides = {}, configuration_provider = nil)
19
- @overrides = overrides
18
+ def initialize(opts = {})
20
19
  @configuration_provider =
21
- configuration_provider || Configuration.identity_provider
20
+ opts[:configuration_provider] || Configuration.identity_provider
22
21
  @binary = RSpec.configuration.terraform_binary
23
22
  @execution_mode = RSpec.configuration.terraform_execution_mode
24
23
  end
25
24
 
26
- def execute(&block)
25
+ def execute(overrides = {}, &block)
27
26
  parameters = with_configuration_provider_parameters(overrides)
28
27
  parameters = with_resolved_vars(parameters, &block)
29
28
 
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../configuration/var_captor'
4
+
5
+ module RSpec
6
+ module Terraform
7
+ module Helpers
8
+ class Var
9
+ attr_reader(:configuration_provider)
10
+
11
+ def initialize(opts = {})
12
+ @configuration_provider =
13
+ opts[:configuration_provider] || Configuration.identity_provider
14
+ end
15
+
16
+ def execute(overrides = {}, &block)
17
+ parameters = with_configuration_provider_parameters(overrides)
18
+ parameters = with_resolved_vars(parameters, &block)
19
+
20
+ parameters[:vars][parameters[:name].to_sym]
21
+ end
22
+
23
+ private
24
+
25
+ def with_configuration_provider_parameters(parameters)
26
+ configuration_provider.resolve(parameters)
27
+ end
28
+
29
+ def with_resolved_vars(parameters, &block)
30
+ return parameters unless block_given?
31
+
32
+ var_captor = Configuration::VarCaptor.new(parameters[:vars] || {})
33
+ block.call(var_captor)
34
+ parameters.merge(vars: var_captor.to_h)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,6 +4,7 @@ require_relative './helpers/apply'
4
4
  require_relative './helpers/destroy'
5
5
  require_relative './helpers/plan'
6
6
  require_relative './helpers/output'
7
+ require_relative './helpers/var'
7
8
 
8
9
  module RSpec
9
10
  module Terraform
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.28'
5
+ VERSION = '0.1.0.pre.31'
6
6
  end
7
7
  end
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.required_ruby_version = '>= 2.7'
39
39
 
40
+ spec.add_dependency 'confidante', '>= 0.27'
40
41
  spec.add_dependency 'rspec', '>= 3.0'
41
42
  spec.add_dependency 'ruby-terraform', '1.7.0.pre.15'
42
43
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.28
4
+ version: 0.1.0.pre.31
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-08-24 00:00:00.000000000 Z
11
+ date: 2022-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: confidante
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.27'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0.27'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -282,14 +296,18 @@ files:
282
296
  - lib/rspec/terraform/configuration.rb
283
297
  - lib/rspec/terraform/configuration/merger.rb
284
298
  - lib/rspec/terraform/configuration/providers.rb
299
+ - lib/rspec/terraform/configuration/providers/base.rb
300
+ - lib/rspec/terraform/configuration/providers/confidante.rb
285
301
  - lib/rspec/terraform/configuration/providers/identity.rb
286
302
  - lib/rspec/terraform/configuration/providers/in_memory.rb
303
+ - lib/rspec/terraform/configuration/providers/seed.rb
287
304
  - lib/rspec/terraform/configuration/var_captor.rb
288
305
  - lib/rspec/terraform/helpers.rb
289
306
  - lib/rspec/terraform/helpers/apply.rb
290
307
  - lib/rspec/terraform/helpers/destroy.rb
291
308
  - lib/rspec/terraform/helpers/output.rb
292
309
  - lib/rspec/terraform/helpers/plan.rb
310
+ - lib/rspec/terraform/helpers/var.rb
293
311
  - lib/rspec/terraform/matchers.rb
294
312
  - lib/rspec/terraform/matchers/include_output_change.rb
295
313
  - lib/rspec/terraform/matchers/include_resource_change.rb