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 +4 -4
- data/Gemfile.lock +23 -1
- data/lib/rspec/terraform/configuration/providers/base.rb +15 -0
- data/lib/rspec/terraform/configuration/providers/confidante.rb +46 -0
- data/lib/rspec/terraform/configuration/providers/identity.rb +3 -1
- data/lib/rspec/terraform/configuration/providers/in_memory.rb +4 -1
- data/lib/rspec/terraform/configuration/providers/seed.rb +39 -0
- data/lib/rspec/terraform/configuration/providers.rb +2 -0
- data/lib/rspec/terraform/configuration.rb +6 -2
- data/lib/rspec/terraform/helpers/apply.rb +4 -5
- data/lib/rspec/terraform/helpers/destroy.rb +4 -5
- data/lib/rspec/terraform/helpers/output.rb +4 -5
- data/lib/rspec/terraform/helpers/plan.rb +4 -5
- data/lib/rspec/terraform/helpers/var.rb +39 -0
- data/lib/rspec/terraform/helpers.rb +1 -0
- data/lib/rspec/terraform/version.rb +1 -1
- data/rspec-terraform.gemspec +1 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaa5c41415be59f0dc571fa3f26d719ef78d5e18604688ade58770f39f3b124a
|
4
|
+
data.tar.gz: a27d2cef84a89423e11ddb46e117c9c37677ae54d1d23d28ba2f5d2ff5a2ac94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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,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
|
@@ -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
|
@@ -12,8 +12,12 @@ module RSpec
|
|
12
12
|
Providers::Identity.new
|
13
13
|
end
|
14
14
|
|
15
|
-
def in_memory_provider(
|
16
|
-
Providers::InMemory.new(
|
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
|
-
:
|
12
|
+
:configuration_provider, :binary, :execution_mode
|
13
13
|
)
|
14
14
|
|
15
|
-
def initialize(
|
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
|
-
:
|
12
|
+
:configuration_provider, :binary, :execution_mode
|
13
13
|
)
|
14
14
|
|
15
|
-
def initialize(
|
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
|
-
:
|
10
|
+
:configuration_provider, :binary, :execution_mode
|
11
11
|
)
|
12
12
|
|
13
|
-
def initialize(
|
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
|
-
:
|
15
|
+
:configuration_provider, :binary, :execution_mode
|
16
16
|
)
|
17
17
|
|
18
|
-
def initialize(
|
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
|
data/rspec-terraform.gemspec
CHANGED
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.
|
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-
|
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
|