rspec-terraform 0.1.0.pre.41 → 0.1.0.pre.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/rspec/terraform/helpers/apply.rb +49 -18
- data/lib/rspec/terraform/helpers/destroy.rb +53 -23
- data/lib/rspec/terraform/helpers/output.rb +25 -3
- data/lib/rspec/terraform/helpers/plan.rb +24 -4
- data/lib/rspec/terraform/helpers.rb +4 -0
- data/lib/rspec/terraform/version.rb +1 -1
- data/rspec-terraform.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84471e75598a3fc301a717d206fd91ba40583271430805b183cbaf58610a8331
|
4
|
+
data.tar.gz: 6178c6b399ff218dffbb21c4f036c64233e3ac84e96ba86660254af7d6f2d4d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b96974345ca144b4314eb2c90237bb238223e706c214fe94b97f4e5462edf969f6b4da8b3cd83a4a81daed33771f18a0e9f415c361ec6f9cb3ebfe97be7b74
|
7
|
+
data.tar.gz: 19651b182453d3de16dfca2b5b4fe205df0d2af4bbfdc80dc1aa4d71298cd359a0ce70655720e100dc21f4f1f19b4784f51bdd56b3adfd63c05c3177a825f21d
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-terraform (0.1.0.pre.
|
4
|
+
rspec-terraform (0.1.0.pre.44)
|
5
5
|
confidante (>= 0.27)
|
6
6
|
rspec (>= 3.0)
|
7
|
-
ruby-terraform (= 1.7.0.pre.
|
7
|
+
ruby-terraform (= 1.7.0.pre.17)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -148,7 +148,7 @@ GEM
|
|
148
148
|
rubocop-rspec (2.12.1)
|
149
149
|
rubocop (~> 1.31)
|
150
150
|
ruby-progressbar (1.11.0)
|
151
|
-
ruby-terraform (1.7.0.pre.
|
151
|
+
ruby-terraform (1.7.0.pre.17)
|
152
152
|
immutable-struct (~> 2.4)
|
153
153
|
lino (~> 3.0)
|
154
154
|
ruby2_keywords (0.0.5)
|
@@ -7,15 +7,26 @@ require_relative '../configuration/var_captor'
|
|
7
7
|
module RSpec
|
8
8
|
module Terraform
|
9
9
|
module Helpers
|
10
|
+
# rubocop:disable Metrics/ClassLength
|
10
11
|
class Apply
|
11
12
|
attr_reader(
|
12
|
-
:configuration_provider,
|
13
|
+
:configuration_provider,
|
14
|
+
:binary,
|
15
|
+
:logger,
|
16
|
+
:stdin,
|
17
|
+
:stdout,
|
18
|
+
:stderr,
|
19
|
+
:execution_mode
|
13
20
|
)
|
14
21
|
|
15
22
|
def initialize(opts = {})
|
16
23
|
@configuration_provider =
|
17
24
|
opts[:configuration_provider] || Configuration.identity_provider
|
18
25
|
@binary = opts[:binary] || 'terraform'
|
26
|
+
@logger = opts[:logger]
|
27
|
+
@stdin = opts[:stdin]
|
28
|
+
@stdout = opts[:stdout]
|
29
|
+
@stderr = opts[:stderr]
|
19
30
|
@execution_mode = opts[:execution_mode] || :in_place
|
20
31
|
end
|
21
32
|
|
@@ -24,15 +35,24 @@ module RSpec
|
|
24
35
|
parameters = with_resolved_vars(parameters, &block)
|
25
36
|
parameters = with_mandatory_parameters(parameters)
|
26
37
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
38
|
+
execute_if_required(parameters) do
|
39
|
+
validate(parameters)
|
40
|
+
clean(parameters)
|
41
|
+
init(parameters)
|
42
|
+
apply(parameters)
|
43
|
+
end
|
32
44
|
end
|
33
45
|
|
34
46
|
private
|
35
47
|
|
48
|
+
def execute_if_required(parameters, &block)
|
49
|
+
only_if = parameters[:only_if]
|
50
|
+
only_if_args = only_if ? [parameters].slice(0, only_if.arity) : []
|
51
|
+
should_execute = only_if ? only_if.call(*only_if_args) : true
|
52
|
+
|
53
|
+
block.call if should_execute
|
54
|
+
end
|
55
|
+
|
36
56
|
def with_configuration_provider_parameters(parameters)
|
37
57
|
configuration_provider.resolve(parameters)
|
38
58
|
end
|
@@ -59,16 +79,6 @@ module RSpec
|
|
59
79
|
}[execution_mode] || []
|
60
80
|
end
|
61
81
|
|
62
|
-
def ensure_required_parameters(parameters)
|
63
|
-
missing_parameters =
|
64
|
-
required_parameters(execution_mode)
|
65
|
-
.filter { |parameter| parameters[parameter].nil? }
|
66
|
-
|
67
|
-
return if missing_parameters.empty?
|
68
|
-
|
69
|
-
raise_missing_parameters(missing_parameters)
|
70
|
-
end
|
71
|
-
|
72
82
|
def raise_missing_parameters(parameters)
|
73
83
|
parameters = parameters.collect { |parameter| "`:#{parameter}`" }
|
74
84
|
if parameters.count == 1
|
@@ -81,6 +91,16 @@ module RSpec
|
|
81
91
|
end
|
82
92
|
end
|
83
93
|
|
94
|
+
def validate(parameters)
|
95
|
+
missing_parameters =
|
96
|
+
required_parameters(execution_mode)
|
97
|
+
.filter { |parameter| parameters[parameter].nil? }
|
98
|
+
|
99
|
+
return if missing_parameters.empty?
|
100
|
+
|
101
|
+
raise_missing_parameters(missing_parameters)
|
102
|
+
end
|
103
|
+
|
84
104
|
def clean(parameters)
|
85
105
|
return unless execution_mode == :isolated
|
86
106
|
|
@@ -97,11 +117,11 @@ module RSpec
|
|
97
117
|
end
|
98
118
|
|
99
119
|
def init_command
|
100
|
-
RubyTerraform::Commands::Init.new(
|
120
|
+
RubyTerraform::Commands::Init.new(command_options)
|
101
121
|
end
|
102
122
|
|
103
123
|
def apply_command
|
104
|
-
RubyTerraform::Commands::Apply.new(
|
124
|
+
RubyTerraform::Commands::Apply.new(command_options)
|
105
125
|
end
|
106
126
|
|
107
127
|
def init_parameters(parameters)
|
@@ -134,7 +154,18 @@ module RSpec
|
|
134
154
|
apply_parameters
|
135
155
|
end
|
136
156
|
# rubocop:enable Metrics/MethodLength
|
157
|
+
|
158
|
+
def command_options
|
159
|
+
{
|
160
|
+
binary: binary,
|
161
|
+
logger: logger,
|
162
|
+
stdin: stdin,
|
163
|
+
stdout: stdout,
|
164
|
+
stderr: stderr
|
165
|
+
}
|
166
|
+
end
|
137
167
|
end
|
168
|
+
# rubocop:enable Metrics/ClassLength
|
138
169
|
end
|
139
170
|
end
|
140
171
|
end
|
@@ -7,15 +7,26 @@ require_relative '../configuration/var_captor'
|
|
7
7
|
module RSpec
|
8
8
|
module Terraform
|
9
9
|
module Helpers
|
10
|
+
# rubocop:disable Metrics/ClassLength
|
10
11
|
class Destroy
|
11
12
|
attr_reader(
|
12
|
-
:configuration_provider,
|
13
|
+
:configuration_provider,
|
14
|
+
:binary,
|
15
|
+
:logger,
|
16
|
+
:stdin,
|
17
|
+
:stdout,
|
18
|
+
:stderr,
|
19
|
+
:execution_mode
|
13
20
|
)
|
14
21
|
|
15
22
|
def initialize(opts = {})
|
16
23
|
@configuration_provider =
|
17
24
|
opts[:configuration_provider] || Configuration.identity_provider
|
18
25
|
@binary = opts[:binary] || 'terraform'
|
26
|
+
@logger = opts[:logger]
|
27
|
+
@stdin = opts[:stdin]
|
28
|
+
@stdout = opts[:stdout]
|
29
|
+
@stderr = opts[:stderr]
|
19
30
|
@execution_mode = opts[:execution_mode] || :in_place
|
20
31
|
end
|
21
32
|
|
@@ -23,15 +34,24 @@ module RSpec
|
|
23
34
|
parameters = with_configuration_provider_parameters(overrides)
|
24
35
|
parameters = with_resolved_vars(parameters, &block)
|
25
36
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
37
|
+
execute_if_required(parameters) do
|
38
|
+
validate(parameters)
|
39
|
+
clean(parameters)
|
40
|
+
init(parameters)
|
41
|
+
destroy(parameters)
|
42
|
+
end
|
31
43
|
end
|
32
44
|
|
33
45
|
private
|
34
46
|
|
47
|
+
def execute_if_required(parameters, &block)
|
48
|
+
only_if = parameters[:only_if]
|
49
|
+
only_if_args = only_if ? [parameters].slice(0, only_if.arity) : []
|
50
|
+
should_execute = only_if ? only_if.call(*only_if_args) : true
|
51
|
+
|
52
|
+
block.call if should_execute
|
53
|
+
end
|
54
|
+
|
35
55
|
def with_configuration_provider_parameters(parameters)
|
36
56
|
configuration_provider.resolve(parameters)
|
37
57
|
end
|
@@ -51,16 +71,6 @@ module RSpec
|
|
51
71
|
}[execution_mode] || []
|
52
72
|
end
|
53
73
|
|
54
|
-
def ensure_required_parameters(parameters)
|
55
|
-
missing_parameters =
|
56
|
-
required_parameters(execution_mode)
|
57
|
-
.filter { |parameter| parameters[parameter].nil? }
|
58
|
-
|
59
|
-
return if missing_parameters.empty?
|
60
|
-
|
61
|
-
raise_missing_parameters(missing_parameters)
|
62
|
-
end
|
63
|
-
|
64
74
|
def raise_missing_parameters(parameters)
|
65
75
|
parameters = parameters.collect { |parameter| "`:#{parameter}`" }
|
66
76
|
if parameters.count == 1
|
@@ -73,6 +83,16 @@ module RSpec
|
|
73
83
|
end
|
74
84
|
end
|
75
85
|
|
86
|
+
def validate(parameters)
|
87
|
+
missing_parameters =
|
88
|
+
required_parameters(execution_mode)
|
89
|
+
.filter { |parameter| parameters[parameter].nil? }
|
90
|
+
|
91
|
+
return if missing_parameters.empty?
|
92
|
+
|
93
|
+
raise_missing_parameters(missing_parameters)
|
94
|
+
end
|
95
|
+
|
76
96
|
def clean(parameters)
|
77
97
|
return unless execution_mode == :isolated
|
78
98
|
|
@@ -89,19 +109,18 @@ module RSpec
|
|
89
109
|
end
|
90
110
|
|
91
111
|
def init_command
|
92
|
-
RubyTerraform::Commands::Init.new(
|
112
|
+
RubyTerraform::Commands::Init.new(command_options)
|
93
113
|
end
|
94
114
|
|
95
115
|
def destroy_command
|
96
|
-
RubyTerraform::Commands::Destroy.new(
|
116
|
+
RubyTerraform::Commands::Destroy.new(command_options)
|
97
117
|
end
|
98
118
|
|
99
119
|
def init_parameters(parameters)
|
100
|
-
init_parameters =
|
101
|
-
parameters
|
102
|
-
|
103
|
-
|
104
|
-
)
|
120
|
+
init_parameters = parameters.merge(
|
121
|
+
chdir: parameters[:configuration_directory],
|
122
|
+
input: false
|
123
|
+
)
|
105
124
|
if execution_mode == :isolated
|
106
125
|
init_parameters =
|
107
126
|
init_parameters.merge(from_module: parameters[:source_directory])
|
@@ -127,7 +146,18 @@ module RSpec
|
|
127
146
|
destroy_parameters
|
128
147
|
end
|
129
148
|
# rubocop:enable Metrics/MethodLength
|
149
|
+
|
150
|
+
def command_options
|
151
|
+
{
|
152
|
+
binary: binary,
|
153
|
+
logger: logger,
|
154
|
+
stdin: stdin,
|
155
|
+
stdout: stdout,
|
156
|
+
stderr: stderr
|
157
|
+
}
|
158
|
+
end
|
130
159
|
end
|
160
|
+
# rubocop:enable Metrics/ClassLength
|
131
161
|
end
|
132
162
|
end
|
133
163
|
end
|
@@ -5,15 +5,26 @@ require 'ruby_terraform'
|
|
5
5
|
module RSpec
|
6
6
|
module Terraform
|
7
7
|
module Helpers
|
8
|
+
# rubocop:disable Metrics/ClassLength
|
8
9
|
class Output
|
9
10
|
attr_reader(
|
10
|
-
:configuration_provider,
|
11
|
+
:configuration_provider,
|
12
|
+
:binary,
|
13
|
+
:logger,
|
14
|
+
:stdin,
|
15
|
+
:stdout,
|
16
|
+
:stderr,
|
17
|
+
:execution_mode
|
11
18
|
)
|
12
19
|
|
13
20
|
def initialize(opts = {})
|
14
21
|
@configuration_provider =
|
15
22
|
opts[:configuration_provider] || Configuration.identity_provider
|
16
23
|
@binary = opts[:binary] || 'terraform'
|
24
|
+
@logger = opts[:logger]
|
25
|
+
@stdin = opts[:stdin]
|
26
|
+
@stdout = opts[:stdout]
|
27
|
+
@stderr = opts[:stderr]
|
17
28
|
@execution_mode = opts[:execution_mode] || :in_place
|
18
29
|
end
|
19
30
|
|
@@ -90,11 +101,11 @@ module RSpec
|
|
90
101
|
end
|
91
102
|
|
92
103
|
def init_command
|
93
|
-
RubyTerraform::Commands::Init.new(
|
104
|
+
RubyTerraform::Commands::Init.new(command_options)
|
94
105
|
end
|
95
106
|
|
96
107
|
def output_command(opts = {})
|
97
|
-
RubyTerraform::Commands::Output.new(
|
108
|
+
RubyTerraform::Commands::Output.new(command_options.merge(opts))
|
98
109
|
end
|
99
110
|
|
100
111
|
def init_parameters(parameters)
|
@@ -123,7 +134,18 @@ module RSpec
|
|
123
134
|
|
124
135
|
output_parameters
|
125
136
|
end
|
137
|
+
|
138
|
+
def command_options
|
139
|
+
{
|
140
|
+
binary: binary,
|
141
|
+
logger: logger,
|
142
|
+
stdin: stdin,
|
143
|
+
stdout: stdout,
|
144
|
+
stderr: stderr
|
145
|
+
}
|
146
|
+
end
|
126
147
|
end
|
127
148
|
end
|
149
|
+
# rubocop:enable Metrics/ClassLength
|
128
150
|
end
|
129
151
|
end
|
@@ -12,13 +12,23 @@ module RSpec
|
|
12
12
|
# rubocop:disable Metrics/ClassLength
|
13
13
|
class Plan
|
14
14
|
attr_reader(
|
15
|
-
:configuration_provider,
|
15
|
+
:configuration_provider,
|
16
|
+
:binary,
|
17
|
+
:logger,
|
18
|
+
:stdin,
|
19
|
+
:stdout,
|
20
|
+
:stderr,
|
21
|
+
:execution_mode
|
16
22
|
)
|
17
23
|
|
18
24
|
def initialize(opts = {})
|
19
25
|
@configuration_provider =
|
20
26
|
opts[:configuration_provider] || Configuration.identity_provider
|
21
27
|
@binary = opts[:binary] || 'terraform'
|
28
|
+
@logger = opts[:logger]
|
29
|
+
@stdin = opts[:stdin]
|
30
|
+
@stdout = opts[:stdout]
|
31
|
+
@stderr = opts[:stderr]
|
22
32
|
@execution_mode = opts[:execution_mode] || :in_place
|
23
33
|
end
|
24
34
|
|
@@ -116,15 +126,15 @@ module RSpec
|
|
116
126
|
end
|
117
127
|
|
118
128
|
def init_command
|
119
|
-
RubyTerraform::Commands::Init.new(
|
129
|
+
RubyTerraform::Commands::Init.new(command_options)
|
120
130
|
end
|
121
131
|
|
122
132
|
def plan_command
|
123
|
-
RubyTerraform::Commands::Plan.new(
|
133
|
+
RubyTerraform::Commands::Plan.new(command_options)
|
124
134
|
end
|
125
135
|
|
126
136
|
def show_command(opts = {})
|
127
|
-
RubyTerraform::Commands::Show.new(
|
137
|
+
RubyTerraform::Commands::Show.new(command_options.merge(opts))
|
128
138
|
end
|
129
139
|
|
130
140
|
def init_parameters(parameters)
|
@@ -167,6 +177,16 @@ module RSpec
|
|
167
177
|
json: true
|
168
178
|
)
|
169
179
|
end
|
180
|
+
|
181
|
+
def command_options
|
182
|
+
{
|
183
|
+
binary: binary,
|
184
|
+
logger: logger,
|
185
|
+
stdin: stdin,
|
186
|
+
stdout: stdout,
|
187
|
+
stderr: stderr
|
188
|
+
}
|
189
|
+
end
|
170
190
|
end
|
171
191
|
# rubocop:enable Metrics/ClassLength
|
172
192
|
end
|
@@ -46,6 +46,10 @@ module RSpec
|
|
46
46
|
|
47
47
|
{
|
48
48
|
binary: config.terraform_binary,
|
49
|
+
logger: config.terraform_logger,
|
50
|
+
stdin: config.terraform_stdin,
|
51
|
+
stdout: config.terraform_stdout,
|
52
|
+
stderr: config.terraform_stderr,
|
49
53
|
execution_mode: config.terraform_execution_mode,
|
50
54
|
configuration_provider: config.terraform_configuration_provider
|
51
55
|
}
|
data/rspec-terraform.gemspec
CHANGED
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
|
40
40
|
spec.add_dependency 'confidante', '>= 0.27'
|
41
41
|
spec.add_dependency 'rspec', '>= 3.0'
|
42
|
-
spec.add_dependency 'ruby-terraform', '1.7.0.pre.
|
42
|
+
spec.add_dependency 'ruby-terraform', '1.7.0.pre.17'
|
43
43
|
|
44
44
|
spec.add_development_dependency 'bundler'
|
45
45
|
spec.add_development_dependency 'faker'
|
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.44
|
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-09-
|
11
|
+
date: 2022-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: confidante
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.7.0.pre.
|
47
|
+
version: 1.7.0.pre.17
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.7.0.pre.
|
54
|
+
version: 1.7.0.pre.17
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|