rspec-terraform 0.1.0.pre.23 → 0.1.0.pre.24
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d7a8abc81671eea02a2fd4f6d3b4f8a3060eca51d50c70ebb76c3b0c064b027
|
4
|
+
data.tar.gz: c423cb560f674bc848cea3fcfdd57ef21e41742bc2a86e0db74755ec0c86c8d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9623a90a33ba6cd9f7948e3856c3954ef822a9eb94bdd48d44126b467985071e4a27654c1d8848168586a9ead4668d6e407e656163c5b1330500eb48e04c1eec
|
7
|
+
data.tar.gz: 0f4766cda2dd7a4fe0335094e155f5731d215b25dde91d135777546839859a82377833485ef0b8459dd32a77b9cf705d3934fa14bd3d2b330273d4895d944782
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Terraform
|
5
|
+
module Configuration
|
6
|
+
class VarCaptor
|
7
|
+
def initialize(vars)
|
8
|
+
@vars = vars
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(method, *args, &_)
|
12
|
+
if method.to_s =~ /.*=$/
|
13
|
+
set_var(method.to_s.chop.to_sym, args[0])
|
14
|
+
else
|
15
|
+
read_var(method)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def respond_to_missing?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_h
|
24
|
+
@vars
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def set_var(var, value)
|
30
|
+
@vars[var] = value
|
31
|
+
end
|
32
|
+
|
33
|
+
def read_var(var)
|
34
|
+
@vars[var]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'ruby_terraform'
|
4
4
|
|
5
|
+
require_relative '../configuration/var_captor'
|
6
|
+
|
5
7
|
module RSpec
|
6
8
|
module Terraform
|
7
9
|
module Helpers
|
@@ -14,20 +16,55 @@ module RSpec
|
|
14
16
|
configuration_provider || Configuration.identity_provider
|
15
17
|
end
|
16
18
|
|
17
|
-
def execute
|
18
|
-
parameters =
|
19
|
-
parameters = parameters
|
19
|
+
def execute(&block)
|
20
|
+
parameters = with_configuration_provider_parameters(overrides)
|
21
|
+
parameters = with_resolved_vars(parameters, &block)
|
22
|
+
parameters = with_mandatory_parameters(parameters)
|
23
|
+
|
24
|
+
ensure_required_parameters(parameters)
|
25
|
+
|
26
|
+
init(parameters)
|
27
|
+
apply(parameters)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def with_configuration_provider_parameters(parameters)
|
33
|
+
configuration_provider.resolve(parameters)
|
34
|
+
end
|
35
|
+
|
36
|
+
def with_resolved_vars(parameters, &block)
|
37
|
+
return parameters unless block_given?
|
38
|
+
|
39
|
+
var_captor = Configuration::VarCaptor.new(parameters[:vars] || {})
|
40
|
+
block.call(var_captor)
|
41
|
+
parameters.merge(vars: var_captor.to_h)
|
42
|
+
end
|
43
|
+
|
44
|
+
def with_mandatory_parameters(parameters)
|
45
|
+
parameters.merge(
|
20
46
|
input: false,
|
21
47
|
auto_approve: true
|
22
48
|
)
|
49
|
+
end
|
23
50
|
|
24
|
-
|
51
|
+
def ensure_required_parameters(parameters)
|
52
|
+
return if parameters[:configuration_directory]
|
53
|
+
|
54
|
+
throw StandardError.new(
|
55
|
+
'No Terraform configuration directory specified.'
|
56
|
+
)
|
25
57
|
end
|
26
58
|
|
27
|
-
|
59
|
+
def init(parameters)
|
60
|
+
init_command.execute(
|
61
|
+
chdir: parameters[:configuration_directory],
|
62
|
+
input: parameters[:input]
|
63
|
+
)
|
64
|
+
end
|
28
65
|
|
29
|
-
def
|
30
|
-
|
66
|
+
def apply(parameters)
|
67
|
+
apply_command.execute(
|
31
68
|
chdir: parameters[:configuration_directory],
|
32
69
|
state: parameters[:state_file],
|
33
70
|
vars: parameters[:vars],
|
@@ -35,6 +72,18 @@ module RSpec
|
|
35
72
|
auto_approve: parameters[:auto_approve]
|
36
73
|
)
|
37
74
|
end
|
75
|
+
|
76
|
+
def init_command
|
77
|
+
RubyTerraform::Commands::Init.new(
|
78
|
+
binary: RSpec.configuration.terraform_binary
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def apply_command
|
83
|
+
RubyTerraform::Commands::Apply.new(
|
84
|
+
binary: RSpec.configuration.terraform_binary
|
85
|
+
)
|
86
|
+
end
|
38
87
|
end
|
39
88
|
end
|
40
89
|
end
|
data/lib/rspec/terraform.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.24
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -284,6 +284,7 @@ files:
|
|
284
284
|
- lib/rspec/terraform/configuration/providers.rb
|
285
285
|
- lib/rspec/terraform/configuration/providers/identity.rb
|
286
286
|
- lib/rspec/terraform/configuration/providers/in_memory.rb
|
287
|
+
- lib/rspec/terraform/configuration/var_captor.rb
|
287
288
|
- lib/rspec/terraform/helpers.rb
|
288
289
|
- lib/rspec/terraform/helpers/apply.rb
|
289
290
|
- lib/rspec/terraform/matchers.rb
|