rspec-terraform 0.1.0.pre.46 → 0.1.0.pre.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rspec/terraform/helpers/actions/apply.rb +49 -0
- data/lib/rspec/terraform/helpers/actions/clean.rb +18 -0
- data/lib/rspec/terraform/helpers/actions/command_instantiation.rb +15 -0
- data/lib/rspec/terraform/helpers/actions/destroy.rb +49 -0
- data/lib/rspec/terraform/helpers/actions/execute_if_required.rb +19 -0
- data/lib/rspec/terraform/helpers/actions/init.rb +50 -0
- data/lib/rspec/terraform/helpers/actions/output.rb +51 -0
- data/lib/rspec/terraform/helpers/actions/plan.rb +53 -0
- data/lib/rspec/terraform/helpers/actions/remove.rb +19 -0
- data/lib/rspec/terraform/helpers/actions/show.rb +52 -0
- data/lib/rspec/terraform/helpers/actions/validate.rb +36 -0
- data/lib/rspec/terraform/helpers/actions.rb +10 -207
- data/lib/rspec/terraform/helpers/apply.rb +7 -0
- data/lib/rspec/terraform/helpers/base.rb +0 -2
- data/lib/rspec/terraform/helpers/destroy.rb +7 -0
- data/lib/rspec/terraform/helpers/output.rb +6 -0
- data/lib/rspec/terraform/helpers/plan.rb +8 -4
- data/lib/rspec/terraform/version.rb +1 -1
- data/lib/rspec/terraform.rb +0 -1
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81533be8b2db5deed030c7d321cf443d1703b7c8e71d7379c70463fab9a9d3f6
|
4
|
+
data.tar.gz: 77b1e6c0b70fc4fd4a258f0a3d6db4c8aa1e404e6059c2eed81ef0163b59509e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c53f5bfe578e18b842e0d509c582fca0c06cb106c10d8fcde12c20361fd2c53b546e3b62dd60109af3bbcb71116c39d4ffcac29703cfa6399b3187da26ab5b58
|
7
|
+
data.tar.gz: 294f50f7e73613ade97534b6706d5df40c6194d50746509826c92f7692484f7cab267e34741257bada91fb1ff92e5e3b5fc7699a506cd6c1870d200f6ba719fb
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby_terraform'
|
4
|
+
|
5
|
+
require_relative './command_instantiation'
|
6
|
+
|
7
|
+
module RSpec
|
8
|
+
module Terraform
|
9
|
+
module Helpers
|
10
|
+
module Actions
|
11
|
+
module Apply
|
12
|
+
include CommandInstantiation
|
13
|
+
|
14
|
+
def apply(parameters)
|
15
|
+
apply_command.execute(apply_parameters(parameters))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def apply_command
|
21
|
+
instantiate_command(RubyTerraform::Commands::Apply)
|
22
|
+
end
|
23
|
+
|
24
|
+
def apply_parameters(parameters)
|
25
|
+
with_apply_state_file_parameters(
|
26
|
+
with_apply_standard_parameters(parameters)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def with_apply_standard_parameters(parameters)
|
31
|
+
parameters.merge(
|
32
|
+
chdir: parameters[:configuration_directory],
|
33
|
+
input: false,
|
34
|
+
auto_approve: true
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def with_apply_state_file_parameters(parameters)
|
39
|
+
if parameters[:state_file]
|
40
|
+
return parameters.merge(state: parameters[:state_file])
|
41
|
+
end
|
42
|
+
|
43
|
+
parameters
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Terraform
|
5
|
+
module Helpers
|
6
|
+
module Actions
|
7
|
+
module Clean
|
8
|
+
def clean(parameters)
|
9
|
+
return unless execution_mode == :isolated
|
10
|
+
|
11
|
+
FileUtils.rm_rf(parameters[:configuration_directory])
|
12
|
+
FileUtils.mkdir_p(parameters[:configuration_directory])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Terraform
|
5
|
+
module Helpers
|
6
|
+
module Actions
|
7
|
+
module CommandInstantiation
|
8
|
+
def instantiate_command(klass, opts = {})
|
9
|
+
klass.new(command_options.merge(opts))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby_terraform'
|
4
|
+
|
5
|
+
require_relative './command_instantiation'
|
6
|
+
|
7
|
+
module RSpec
|
8
|
+
module Terraform
|
9
|
+
module Helpers
|
10
|
+
module Actions
|
11
|
+
module Destroy
|
12
|
+
include CommandInstantiation
|
13
|
+
|
14
|
+
def destroy(parameters)
|
15
|
+
destroy_command.execute(destroy_parameters(parameters))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def destroy_command
|
21
|
+
instantiate_command(RubyTerraform::Commands::Destroy)
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy_parameters(parameters)
|
25
|
+
with_destroy_state_file_parameters(
|
26
|
+
with_destroy_standard_parameters(parameters)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def with_destroy_standard_parameters(parameters)
|
31
|
+
parameters.merge(
|
32
|
+
chdir: parameters[:configuration_directory],
|
33
|
+
input: false,
|
34
|
+
auto_approve: true
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def with_destroy_state_file_parameters(parameters)
|
39
|
+
if parameters[:state_file]
|
40
|
+
return parameters.merge(state: parameters[:state_file])
|
41
|
+
end
|
42
|
+
|
43
|
+
parameters
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Terraform
|
5
|
+
module Helpers
|
6
|
+
module Actions
|
7
|
+
module ExecuteIfRequired
|
8
|
+
def execute_if_required(parameters, &block)
|
9
|
+
only_if = parameters[:only_if]
|
10
|
+
only_if_args = only_if ? [parameters].slice(0, only_if.arity) : []
|
11
|
+
should_execute = only_if ? only_if.call(*only_if_args) : true
|
12
|
+
|
13
|
+
block.call if should_execute
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby_terraform'
|
4
|
+
|
5
|
+
require_relative './command_instantiation'
|
6
|
+
|
7
|
+
module RSpec
|
8
|
+
module Terraform
|
9
|
+
module Helpers
|
10
|
+
module Actions
|
11
|
+
module Init
|
12
|
+
include CommandInstantiation
|
13
|
+
|
14
|
+
def init(parameters)
|
15
|
+
init_command.execute(init_parameters(parameters))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def init_command
|
21
|
+
instantiate_command(RubyTerraform::Commands::Init)
|
22
|
+
end
|
23
|
+
|
24
|
+
def init_parameters(parameters)
|
25
|
+
with_init_execution_mode_parameters(
|
26
|
+
with_init_standard_parameters(parameters)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def with_init_standard_parameters(parameters)
|
31
|
+
parameters.merge(
|
32
|
+
chdir: parameters[:configuration_directory],
|
33
|
+
input: false
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def with_init_execution_mode_parameters(parameters)
|
38
|
+
if execution_mode == :isolated
|
39
|
+
return parameters.merge(
|
40
|
+
from_module: parameters[:source_directory]
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
parameters
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby_terraform'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
require_relative './command_instantiation'
|
7
|
+
|
8
|
+
module RSpec
|
9
|
+
module Terraform
|
10
|
+
module Helpers
|
11
|
+
module Actions
|
12
|
+
module Output
|
13
|
+
include CommandInstantiation
|
14
|
+
|
15
|
+
def output(parameters)
|
16
|
+
stdout = StringIO.new
|
17
|
+
output_command(stdout: stdout)
|
18
|
+
.execute(output_parameters(parameters))
|
19
|
+
stdout.string
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def output_command(opts = {})
|
25
|
+
instantiate_command(RubyTerraform::Commands::Output, opts)
|
26
|
+
end
|
27
|
+
|
28
|
+
def output_parameters(parameters)
|
29
|
+
with_output_state_file_parameters(
|
30
|
+
with_output_standard_parameters(parameters)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_output_standard_parameters(parameters)
|
35
|
+
parameters.merge(
|
36
|
+
chdir: parameters[:configuration_directory]
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def with_output_state_file_parameters(parameters)
|
41
|
+
if parameters[:state_file]
|
42
|
+
return parameters.merge(state: parameters[:state_file])
|
43
|
+
end
|
44
|
+
|
45
|
+
parameters
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby_terraform'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
require_relative './command_instantiation'
|
7
|
+
|
8
|
+
module RSpec
|
9
|
+
module Terraform
|
10
|
+
module Helpers
|
11
|
+
module Actions
|
12
|
+
module Plan
|
13
|
+
include CommandInstantiation
|
14
|
+
|
15
|
+
def plan(parameters)
|
16
|
+
plan_parameters = plan_parameters(parameters)
|
17
|
+
plan_command.execute(plan_parameters)
|
18
|
+
plan_parameters[:out]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def plan_command
|
24
|
+
instantiate_command(RubyTerraform::Commands::Plan)
|
25
|
+
end
|
26
|
+
|
27
|
+
def plan_parameters(parameters)
|
28
|
+
with_plan_state_file_parameters(
|
29
|
+
with_plan_standard_parameters(parameters)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def with_plan_standard_parameters(parameters)
|
34
|
+
parameters.merge(
|
35
|
+
chdir: parameters[:configuration_directory],
|
36
|
+
out: parameters[:plan_file_name] ||
|
37
|
+
"#{SecureRandom.hex[0, 10]}.tfplan",
|
38
|
+
input: false
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def with_plan_state_file_parameters(parameters)
|
43
|
+
if parameters[:state_file]
|
44
|
+
return parameters.merge(state: parameters[:state_file])
|
45
|
+
end
|
46
|
+
|
47
|
+
parameters
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
module Terraform
|
7
|
+
module Helpers
|
8
|
+
module Actions
|
9
|
+
module Remove
|
10
|
+
def remove(parameters, file)
|
11
|
+
FileUtils.rm_f(
|
12
|
+
File.join(parameters[:configuration_directory], file)
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby_terraform'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
require_relative './command_instantiation'
|
7
|
+
|
8
|
+
module RSpec
|
9
|
+
module Terraform
|
10
|
+
module Helpers
|
11
|
+
module Actions
|
12
|
+
module Show
|
13
|
+
include CommandInstantiation
|
14
|
+
|
15
|
+
def show(parameters, plan_file)
|
16
|
+
stdout = StringIO.new
|
17
|
+
show_command(stdout: stdout)
|
18
|
+
.execute(show_parameters(parameters, plan_file))
|
19
|
+
stdout.string
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def show_command(opts = {})
|
25
|
+
instantiate_command(RubyTerraform::Commands::Show, opts)
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_parameters(parameters, plan_file)
|
29
|
+
with_show_plan_file_parameters(
|
30
|
+
with_show_standard_parameters(parameters),
|
31
|
+
plan_file
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_show_standard_parameters(parameters)
|
36
|
+
parameters.merge(
|
37
|
+
chdir: parameters[:configuration_directory],
|
38
|
+
no_color: true,
|
39
|
+
json: true
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def with_show_plan_file_parameters(parameters, plan_file)
|
44
|
+
parameters.merge(
|
45
|
+
path: plan_file
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Terraform
|
5
|
+
module Helpers
|
6
|
+
module Actions
|
7
|
+
module Validate
|
8
|
+
def validate(parameters)
|
9
|
+
missing_parameters =
|
10
|
+
required_parameters(execution_mode)
|
11
|
+
.filter { |parameter| parameters[parameter].nil? }
|
12
|
+
|
13
|
+
return if missing_parameters.empty?
|
14
|
+
|
15
|
+
raise_missing_parameters(missing_parameters)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def raise_missing_parameters(parameters)
|
21
|
+
parameters = parameters.collect { |parameter| "`:#{parameter}`" }
|
22
|
+
if parameters.count == 1
|
23
|
+
raise StandardError,
|
24
|
+
"Required parameter: #{parameters[0]} missing."
|
25
|
+
else
|
26
|
+
parameters =
|
27
|
+
"#{parameters[..-2].join(', ')} and #{parameters[-1]}"
|
28
|
+
raise StandardError,
|
29
|
+
"Required parameters: #{parameters} missing."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,209 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
should_execute = only_if ? only_if.call(*only_if_args) : true
|
14
|
-
|
15
|
-
block.call if should_execute
|
16
|
-
end
|
17
|
-
|
18
|
-
def clean(parameters)
|
19
|
-
return unless execution_mode == :isolated
|
20
|
-
|
21
|
-
FileUtils.rm_rf(parameters[:configuration_directory])
|
22
|
-
FileUtils.mkdir_p(parameters[:configuration_directory])
|
23
|
-
end
|
24
|
-
|
25
|
-
def remove(parameters, file)
|
26
|
-
FileUtils.rm_f(
|
27
|
-
File.join(parameters[:configuration_directory], file)
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
def validate(parameters)
|
32
|
-
missing_parameters =
|
33
|
-
required_parameters(execution_mode)
|
34
|
-
.filter { |parameter| parameters[parameter].nil? }
|
35
|
-
|
36
|
-
return if missing_parameters.empty?
|
37
|
-
|
38
|
-
raise_missing_parameters(missing_parameters)
|
39
|
-
end
|
40
|
-
|
41
|
-
def init(parameters)
|
42
|
-
init_command.execute(init_parameters(parameters))
|
43
|
-
end
|
44
|
-
|
45
|
-
def apply(parameters)
|
46
|
-
apply_command.execute(apply_parameters(parameters))
|
47
|
-
end
|
48
|
-
|
49
|
-
def destroy(parameters)
|
50
|
-
destroy_command.execute(destroy_parameters(parameters))
|
51
|
-
end
|
52
|
-
|
53
|
-
def plan(parameters)
|
54
|
-
plan_parameters = plan_parameters(parameters)
|
55
|
-
plan_command.execute(plan_parameters)
|
56
|
-
plan_parameters[:out]
|
57
|
-
end
|
58
|
-
|
59
|
-
def show(parameters, plan_file)
|
60
|
-
stdout = StringIO.new
|
61
|
-
show_command(stdout: stdout)
|
62
|
-
.execute(show_parameters(parameters, plan_file))
|
63
|
-
stdout.string
|
64
|
-
end
|
65
|
-
|
66
|
-
def output(parameters)
|
67
|
-
stdout = StringIO.new
|
68
|
-
output_command(stdout: stdout)
|
69
|
-
.execute(output_parameters(parameters))
|
70
|
-
stdout.string
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def raise_missing_parameters(parameters)
|
76
|
-
parameters = parameters.collect { |parameter| "`:#{parameter}`" }
|
77
|
-
if parameters.count == 1
|
78
|
-
raise StandardError,
|
79
|
-
"Required parameter: #{parameters[0]} missing."
|
80
|
-
else
|
81
|
-
parameters = "#{parameters[..-2].join(', ')} and #{parameters[-1]}"
|
82
|
-
raise StandardError,
|
83
|
-
"Required parameters: #{parameters} missing."
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def instantiate_command(klass, opts = {})
|
88
|
-
klass.new(command_options.merge(opts))
|
89
|
-
end
|
90
|
-
|
91
|
-
def init_command
|
92
|
-
instantiate_command(RubyTerraform::Commands::Init)
|
93
|
-
end
|
94
|
-
|
95
|
-
def apply_command
|
96
|
-
instantiate_command(RubyTerraform::Commands::Apply)
|
97
|
-
end
|
98
|
-
|
99
|
-
def destroy_command
|
100
|
-
instantiate_command(RubyTerraform::Commands::Destroy)
|
101
|
-
end
|
102
|
-
|
103
|
-
def plan_command
|
104
|
-
instantiate_command(RubyTerraform::Commands::Plan)
|
105
|
-
end
|
106
|
-
|
107
|
-
def show_command(opts = {})
|
108
|
-
instantiate_command(RubyTerraform::Commands::Show, opts)
|
109
|
-
end
|
110
|
-
|
111
|
-
def output_command(opts = {})
|
112
|
-
instantiate_command(RubyTerraform::Commands::Output, opts)
|
113
|
-
end
|
114
|
-
|
115
|
-
def init_parameters(parameters)
|
116
|
-
init_parameters = parameters.merge(
|
117
|
-
chdir: parameters[:configuration_directory],
|
118
|
-
input: false
|
119
|
-
)
|
120
|
-
if execution_mode == :isolated
|
121
|
-
init_parameters =
|
122
|
-
init_parameters.merge(from_module: parameters[:source_directory])
|
123
|
-
end
|
124
|
-
|
125
|
-
init_parameters
|
126
|
-
end
|
127
|
-
|
128
|
-
# rubocop:disable Metrics/MethodLength
|
129
|
-
def apply_parameters(parameters)
|
130
|
-
apply_parameters =
|
131
|
-
parameters.merge(
|
132
|
-
chdir: parameters[:configuration_directory],
|
133
|
-
input: false,
|
134
|
-
auto_approve: true
|
135
|
-
)
|
136
|
-
|
137
|
-
if parameters[:state_file]
|
138
|
-
apply_parameters =
|
139
|
-
apply_parameters.merge(state: parameters[:state_file])
|
140
|
-
end
|
141
|
-
|
142
|
-
apply_parameters
|
143
|
-
end
|
144
|
-
# rubocop:enable Metrics/MethodLength
|
145
|
-
|
146
|
-
# rubocop:disable Metrics/MethodLength
|
147
|
-
def destroy_parameters(parameters)
|
148
|
-
destroy_parameters =
|
149
|
-
parameters.merge(
|
150
|
-
chdir: parameters[:configuration_directory],
|
151
|
-
input: false,
|
152
|
-
auto_approve: true
|
153
|
-
)
|
154
|
-
|
155
|
-
if parameters[:state_file]
|
156
|
-
destroy_parameters =
|
157
|
-
destroy_parameters.merge(state: parameters[:state_file])
|
158
|
-
end
|
159
|
-
|
160
|
-
destroy_parameters
|
161
|
-
end
|
162
|
-
# rubocop:enable Metrics/MethodLength
|
163
|
-
|
164
|
-
# rubocop:disable Metrics/MethodLength
|
165
|
-
def plan_parameters(parameters)
|
166
|
-
plan_parameters =
|
167
|
-
parameters.merge(
|
168
|
-
chdir: parameters[:configuration_directory],
|
169
|
-
out: parameters[:plan_file_name] ||
|
170
|
-
"#{SecureRandom.hex[0, 10]}.tfplan",
|
171
|
-
input: false
|
172
|
-
)
|
173
|
-
|
174
|
-
if parameters[:state_file]
|
175
|
-
plan_parameters =
|
176
|
-
plan_parameters.merge(state: parameters[:state_file])
|
177
|
-
end
|
178
|
-
|
179
|
-
plan_parameters
|
180
|
-
end
|
181
|
-
# rubocop:enable Metrics/MethodLength
|
182
|
-
|
183
|
-
def show_parameters(parameters, plan_file)
|
184
|
-
parameters.merge(
|
185
|
-
chdir: parameters[:configuration_directory],
|
186
|
-
path: plan_file,
|
187
|
-
no_color: true,
|
188
|
-
json: true
|
189
|
-
)
|
190
|
-
end
|
191
|
-
|
192
|
-
def output_parameters(parameters)
|
193
|
-
output_parameters =
|
194
|
-
parameters.merge(
|
195
|
-
chdir: parameters[:configuration_directory]
|
196
|
-
)
|
197
|
-
|
198
|
-
if parameters[:state_file]
|
199
|
-
output_parameters =
|
200
|
-
output_parameters.merge(state: parameters[:state_file])
|
201
|
-
end
|
202
|
-
|
203
|
-
output_parameters
|
204
|
-
end
|
205
|
-
end
|
206
|
-
# rubocop:enable Metrics/ModuleLength
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
3
|
+
require_relative './actions/clean'
|
4
|
+
require_relative './actions/validate'
|
5
|
+
require_relative './actions/init'
|
6
|
+
require_relative './actions/apply'
|
7
|
+
require_relative './actions/destroy'
|
8
|
+
require_relative './actions/plan'
|
9
|
+
require_relative './actions/output'
|
10
|
+
require_relative './actions/show'
|
11
|
+
require_relative './actions/remove'
|
12
|
+
require_relative './actions/execute_if_required'
|
@@ -3,11 +3,18 @@
|
|
3
3
|
require 'ruby_terraform'
|
4
4
|
|
5
5
|
require_relative './base'
|
6
|
+
require_relative './actions'
|
6
7
|
|
7
8
|
module RSpec
|
8
9
|
module Terraform
|
9
10
|
module Helpers
|
10
11
|
class Apply < Base
|
12
|
+
include Actions::ExecuteIfRequired
|
13
|
+
include Actions::Validate
|
14
|
+
include Actions::Clean
|
15
|
+
include Actions::Init
|
16
|
+
include Actions::Apply
|
17
|
+
|
11
18
|
def execute(overrides = {}, &block)
|
12
19
|
parameters = resolve_parameters(overrides, &block)
|
13
20
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative './actions'
|
4
3
|
require_relative './parameters'
|
5
4
|
|
6
5
|
module RSpec
|
@@ -8,7 +7,6 @@ module RSpec
|
|
8
7
|
module Helpers
|
9
8
|
class Base
|
10
9
|
include Parameters
|
11
|
-
include Actions
|
12
10
|
|
13
11
|
attr_reader(
|
14
12
|
:configuration_provider,
|
@@ -3,11 +3,18 @@
|
|
3
3
|
require 'ruby_terraform'
|
4
4
|
|
5
5
|
require_relative './base'
|
6
|
+
require_relative './actions'
|
6
7
|
|
7
8
|
module RSpec
|
8
9
|
module Terraform
|
9
10
|
module Helpers
|
10
11
|
class Destroy < Base
|
12
|
+
include Actions::ExecuteIfRequired
|
13
|
+
include Actions::Validate
|
14
|
+
include Actions::Clean
|
15
|
+
include Actions::Init
|
16
|
+
include Actions::Destroy
|
17
|
+
|
11
18
|
def execute(overrides = {}, &block)
|
12
19
|
parameters = resolve_parameters(overrides, &block)
|
13
20
|
|
@@ -3,11 +3,17 @@
|
|
3
3
|
require 'ruby_terraform'
|
4
4
|
|
5
5
|
require_relative './base'
|
6
|
+
require_relative './actions'
|
6
7
|
|
7
8
|
module RSpec
|
8
9
|
module Terraform
|
9
10
|
module Helpers
|
10
11
|
class Output < Base
|
12
|
+
include Actions::Validate
|
13
|
+
include Actions::Clean
|
14
|
+
include Actions::Init
|
15
|
+
include Actions::Output
|
16
|
+
|
11
17
|
def execute(overrides = {})
|
12
18
|
parameters = resolve_parameters(overrides)
|
13
19
|
|
@@ -1,15 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ruby_terraform'
|
4
|
-
require 'securerandom'
|
5
|
-
require 'stringio'
|
6
|
-
|
7
3
|
require_relative './base'
|
4
|
+
require_relative './actions'
|
8
5
|
|
9
6
|
module RSpec
|
10
7
|
module Terraform
|
11
8
|
module Helpers
|
12
9
|
class Plan < Base
|
10
|
+
include Actions::Validate
|
11
|
+
include Actions::Clean
|
12
|
+
include Actions::Init
|
13
|
+
include Actions::Plan
|
14
|
+
include Actions::Show
|
15
|
+
include Actions::Remove
|
16
|
+
|
13
17
|
def execute(overrides = {}, &block)
|
14
18
|
parameters = resolve_parameters(overrides, &block)
|
15
19
|
|
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.47
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: confidante
|
@@ -305,6 +305,17 @@ files:
|
|
305
305
|
- lib/rspec/terraform/configuration/var_captor.rb
|
306
306
|
- lib/rspec/terraform/helpers.rb
|
307
307
|
- lib/rspec/terraform/helpers/actions.rb
|
308
|
+
- lib/rspec/terraform/helpers/actions/apply.rb
|
309
|
+
- lib/rspec/terraform/helpers/actions/clean.rb
|
310
|
+
- lib/rspec/terraform/helpers/actions/command_instantiation.rb
|
311
|
+
- lib/rspec/terraform/helpers/actions/destroy.rb
|
312
|
+
- lib/rspec/terraform/helpers/actions/execute_if_required.rb
|
313
|
+
- lib/rspec/terraform/helpers/actions/init.rb
|
314
|
+
- lib/rspec/terraform/helpers/actions/output.rb
|
315
|
+
- lib/rspec/terraform/helpers/actions/plan.rb
|
316
|
+
- lib/rspec/terraform/helpers/actions/remove.rb
|
317
|
+
- lib/rspec/terraform/helpers/actions/show.rb
|
318
|
+
- lib/rspec/terraform/helpers/actions/validate.rb
|
308
319
|
- lib/rspec/terraform/helpers/apply.rb
|
309
320
|
- lib/rspec/terraform/helpers/base.rb
|
310
321
|
- lib/rspec/terraform/helpers/destroy.rb
|