kitchen-terraform 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +40 -43
- data/lib/kitchen/{terraform/client.rb → driver.rb} +4 -5
- data/lib/kitchen/driver/terraform.rb +367 -300
- data/lib/kitchen/provisioner.rb +22 -0
- data/lib/kitchen/provisioner/terraform.rb +70 -13
- data/lib/kitchen/terraform/client_version_verifier.rb +8 -3
- data/lib/kitchen/terraform/config_attribute.rb +0 -5
- data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +21 -5
- data/lib/kitchen/terraform/config_attribute/color.rb +15 -4
- data/lib/kitchen/terraform/config_attribute/command_timeout.rb +7 -4
- data/lib/kitchen/terraform/config_attribute/groups.rb +63 -27
- data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +16 -7
- data/lib/kitchen/terraform/config_attribute/parallelism.rb +12 -4
- data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +13 -6
- data/lib/kitchen/terraform/config_attribute/{directory.rb → root_module_directory.rb} +9 -8
- data/lib/kitchen/terraform/config_attribute/variable_files.rb +19 -2
- data/lib/kitchen/terraform/config_attribute/variables.rb +18 -4
- data/lib/kitchen/terraform/configurable.rb +0 -19
- data/lib/kitchen/terraform/shell_out.rb +66 -0
- data/lib/kitchen/terraform/version.rb +1 -1
- data/lib/kitchen/verifier.rb +22 -0
- data/lib/kitchen/verifier/terraform.rb +116 -60
- data/lib/kitchen/verifier/terraform/configure_inspec_runner_attributes.rb +37 -24
- data/lib/kitchen/verifier/terraform/enumerate_groups_and_hostnames.rb +35 -17
- metadata +29 -12
- metadata.gz.sig +3 -2
- data/lib/kitchen/terraform/clear_directory.rb +0 -38
- data/lib/kitchen/terraform/client/command.rb +0 -168
- data/lib/kitchen/terraform/client/options.rb +0 -275
- data/lib/kitchen/terraform/config_attribute/state.rb +0 -55
- data/lib/kitchen/terraform/config_attribute/verify_plugins.rb +0 -52
- data/lib/kitchen/terraform/create_directories.rb +0 -39
@@ -63,34 +63,47 @@ module ::Kitchen::Verifier::Terraform::ConfigureInspecRunnerAttributes
|
|
63
63
|
|
64
64
|
# Invokes the function
|
65
65
|
#
|
66
|
-
# @param
|
67
|
-
# @param
|
68
|
-
# @
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
# @param group [::Hash] a kitchen-terraform verifier group.
|
67
|
+
# @param output [::String] the output of the Terraform state.
|
68
|
+
# @return [::Dry::Monads::Either] the result of the function.
|
69
|
+
def self.call(group:, output:)
|
70
|
+
Right(
|
71
|
+
group
|
72
|
+
.fetch(
|
73
|
+
:attributes,
|
74
|
+
{}
|
75
|
+
)
|
76
|
+
)
|
77
|
+
.bind do |group_attributes|
|
78
|
+
Right(
|
75
79
|
output
|
76
|
-
|
80
|
+
.keys
|
81
|
+
.+(group_attributes.keys)
|
82
|
+
.zip(
|
83
|
+
output
|
84
|
+
.keys
|
85
|
+
.+(group_attributes.values)
|
86
|
+
)
|
87
|
+
)
|
77
88
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
.bind do |unresolved_attributes|
|
90
|
+
Try ::KeyError do
|
91
|
+
unresolved_attributes
|
92
|
+
.reduce ::Hash.new do |resolved_attributes, (attribute_name, output_name)|
|
93
|
+
resolved_attributes
|
94
|
+
.merge(
|
95
|
+
attribute_name
|
96
|
+
.to_s =>
|
97
|
+
output
|
98
|
+
.fetch(output_name.to_s)
|
99
|
+
.fetch("value")
|
100
|
+
)
|
101
|
+
end
|
82
102
|
end
|
83
|
-
[attributes, output]
|
84
103
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
attributes.store attribute_name.to_s, output.fetch(output_name.to_s).fetch("value")
|
89
|
-
end
|
104
|
+
.to_either
|
105
|
+
.or do |error|
|
106
|
+
Left "Configuring InSpec runner attributes resulted in failure: #{error}"
|
90
107
|
end
|
91
|
-
Right attributes
|
92
|
-
end.to_either.or do |error|
|
93
|
-
Left "configuring Inspec::Runner attributes failed\n#{error}"
|
94
|
-
end
|
95
108
|
end
|
96
109
|
end
|
@@ -38,30 +38,48 @@ module ::Kitchen::Verifier::Terraform::EnumerateGroupsAndHostnames
|
|
38
38
|
|
39
39
|
# Invokes the function.
|
40
40
|
#
|
41
|
-
# @param driver [::Kitchen::Driver::Terraform] a kitchen-terraform driver.
|
42
41
|
# @param groups [::Array] a collection of groups.
|
43
42
|
# @return [::Dry::Monads::Either] the result of the function.
|
44
43
|
# @yieldparam group [::Hash] the group from which hostnamess are being enumerated.
|
45
44
|
# @yieldparam hostname [::String] a hostname from the group.
|
46
|
-
def self.call(
|
47
|
-
List(groups)
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
def self.call(groups:, output:)
|
46
|
+
List(groups)
|
47
|
+
.fmap(&method(:Right))
|
48
|
+
.typed(::Dry::Monads::Either)
|
49
|
+
.traverse do |member|
|
50
|
+
member
|
51
|
+
.bind do |group|
|
51
52
|
Try ::KeyError do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
Maybe(group[:hostnames])
|
54
|
+
.fmap do |hostnames_output_name|
|
55
|
+
output
|
56
|
+
.fetch(hostnames_output_name)
|
57
|
+
.fetch("value")
|
58
|
+
end
|
59
|
+
.or do
|
60
|
+
Right "localhost"
|
61
|
+
end
|
62
|
+
.fmap do |hostnames|
|
63
|
+
Array(hostnames)
|
64
|
+
.each do |hostname|
|
65
|
+
yield(
|
66
|
+
group: group,
|
67
|
+
hostname: hostname
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
57
71
|
end
|
72
|
+
.to_either
|
58
73
|
end
|
59
|
-
else
|
60
|
-
Right block.call group: group, hostname: "localhost"
|
61
|
-
end
|
62
74
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
75
|
+
.bind do
|
76
|
+
Right "Enumeration of groups and hostnames resulted in success"
|
77
|
+
end
|
78
|
+
.or do |error|
|
79
|
+
Left(
|
80
|
+
"Enumeration of groups and hostnames resulted in failure due to the omission of the configured :hostnames " \
|
81
|
+
"output or an unexpected output structure: #{error}"
|
82
|
+
)
|
83
|
+
end
|
66
84
|
end
|
67
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-terraform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lane
|
@@ -54,7 +54,7 @@ cert_chain:
|
|
54
54
|
XjOfZudLs1zJ8ZNOuwj6KkGJ9J3XHd9hM95MtBEWlxAfYdCuW1+v7zCTfbieBEba
|
55
55
|
UIyyldg4TuVcuRs8uKJyempT0hqx2DniseBWw3nvtgom3A==
|
56
56
|
-----END CERTIFICATE-----
|
57
|
-
date: 2017-
|
57
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
58
58
|
dependencies:
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: codeclimate-test-reporter
|
@@ -238,6 +238,26 @@ dependencies:
|
|
238
238
|
- - "~>"
|
239
239
|
- !ruby/object:Gem::Version
|
240
240
|
version: '0.10'
|
241
|
+
- !ruby/object:Gem::Dependency
|
242
|
+
name: inspec
|
243
|
+
requirement: !ruby/object:Gem::Requirement
|
244
|
+
requirements:
|
245
|
+
- - ">="
|
246
|
+
- !ruby/object:Gem::Version
|
247
|
+
version: 0.34.0
|
248
|
+
- - "<="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: 1.44.8
|
251
|
+
type: :runtime
|
252
|
+
prerelease: false
|
253
|
+
version_requirements: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: 0.34.0
|
258
|
+
- - "<="
|
259
|
+
- !ruby/object:Gem::Version
|
260
|
+
version: 1.44.8
|
241
261
|
- !ruby/object:Gem::Dependency
|
242
262
|
name: kitchen-inspec
|
243
263
|
requirement: !ruby/object:Gem::Requirement
|
@@ -289,27 +309,23 @@ extra_rdoc_files: []
|
|
289
309
|
files:
|
290
310
|
- LICENSE
|
291
311
|
- README.md
|
312
|
+
- lib/kitchen/driver.rb
|
292
313
|
- lib/kitchen/driver/terraform.rb
|
314
|
+
- lib/kitchen/provisioner.rb
|
293
315
|
- lib/kitchen/provisioner/terraform.rb
|
294
316
|
- lib/kitchen/terraform.rb
|
295
|
-
- lib/kitchen/terraform/clear_directory.rb
|
296
|
-
- lib/kitchen/terraform/client.rb
|
297
|
-
- lib/kitchen/terraform/client/command.rb
|
298
|
-
- lib/kitchen/terraform/client/options.rb
|
299
317
|
- lib/kitchen/terraform/client_version_verifier.rb
|
300
318
|
- lib/kitchen/terraform/config_attribute.rb
|
301
319
|
- lib/kitchen/terraform/config_attribute/backend_configurations.rb
|
302
320
|
- lib/kitchen/terraform/config_attribute/color.rb
|
303
321
|
- lib/kitchen/terraform/config_attribute/command_timeout.rb
|
304
|
-
- lib/kitchen/terraform/config_attribute/directory.rb
|
305
322
|
- lib/kitchen/terraform/config_attribute/groups.rb
|
306
323
|
- lib/kitchen/terraform/config_attribute/lock_timeout.rb
|
307
324
|
- lib/kitchen/terraform/config_attribute/parallelism.rb
|
308
325
|
- lib/kitchen/terraform/config_attribute/plugin_directory.rb
|
309
|
-
- lib/kitchen/terraform/config_attribute/
|
326
|
+
- lib/kitchen/terraform/config_attribute/root_module_directory.rb
|
310
327
|
- lib/kitchen/terraform/config_attribute/variable_files.rb
|
311
328
|
- lib/kitchen/terraform/config_attribute/variables.rb
|
312
|
-
- lib/kitchen/terraform/config_attribute/verify_plugins.rb
|
313
329
|
- lib/kitchen/terraform/config_attribute_cacher.rb
|
314
330
|
- lib/kitchen/terraform/config_attribute_definer.rb
|
315
331
|
- lib/kitchen/terraform/config_predicates.rb
|
@@ -323,9 +339,10 @@ files:
|
|
323
339
|
- lib/kitchen/terraform/config_schemas/optional_string.rb
|
324
340
|
- lib/kitchen/terraform/config_schemas/string.rb
|
325
341
|
- lib/kitchen/terraform/configurable.rb
|
326
|
-
- lib/kitchen/terraform/create_directories.rb
|
327
342
|
- lib/kitchen/terraform/file_path_config_attribute_definer.rb
|
343
|
+
- lib/kitchen/terraform/shell_out.rb
|
328
344
|
- lib/kitchen/terraform/version.rb
|
345
|
+
- lib/kitchen/verifier.rb
|
329
346
|
- lib/kitchen/verifier/terraform.rb
|
330
347
|
- lib/kitchen/verifier/terraform/configure_inspec_runner_attributes.rb
|
331
348
|
- lib/kitchen/verifier/terraform/configure_inspec_runner_backend.rb
|
@@ -357,9 +374,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
357
374
|
- !ruby/object:Gem::Version
|
358
375
|
version: '0'
|
359
376
|
requirements:
|
360
|
-
- Terraform
|
377
|
+
- Terraform >= 0.10.2, < 0.12.0
|
361
378
|
rubyforge_project:
|
362
|
-
rubygems_version: 2.
|
379
|
+
rubygems_version: 2.7.3
|
363
380
|
signing_key:
|
364
381
|
specification_version: 4
|
365
382
|
summary: Test Kitchen plugins for testing Terraform configuration
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.�Հ�"�@W�?���x/a�_�L���4����rا���S�*�<�$2�8
|
2
|
+
�_��W�<�b�a�8M�;+^��������%�j��ԯ�x$�dM��.������"�
|
3
|
+
��S��^�m���+��5F��ؖ%l��)�em�c
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2016 New Context Services, Inc.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
require "dry/monads"
|
18
|
-
require "fileutils"
|
19
|
-
require "kitchen/terraform"
|
20
|
-
|
21
|
-
# Clears a directory on the filesystem of specified files.
|
22
|
-
module ::Kitchen::Terraform::ClearDirectory
|
23
|
-
extend ::Dry::Monads::Either::Mixin
|
24
|
-
|
25
|
-
# Invokes the function.
|
26
|
-
#
|
27
|
-
# @param directory ::String the path of the directory to clear.
|
28
|
-
# @param files [::Array<::String>, ::String] a list of files to clear from the directory.
|
29
|
-
# @return [::Dry::Monads::Either] the result of the function.
|
30
|
-
def self.call(directory:, files:)
|
31
|
-
::FileUtils.safe_unlink(
|
32
|
-
files.map do |file|
|
33
|
-
::Dir.glob ::File.join directory, file
|
34
|
-
end.flatten
|
35
|
-
)
|
36
|
-
Right "Cleared directory \"#{directory}\" of files #{files}"
|
37
|
-
end
|
38
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2016 New Context Services, Inc.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
require "dry/monads"
|
18
|
-
require "kitchen/terraform/client"
|
19
|
-
require "mixlib/shellout"
|
20
|
-
require "kitchen/terraform/client/options"
|
21
|
-
|
22
|
-
# Represents the result of running a Terraform command.
|
23
|
-
#
|
24
|
-
# @see https://www.terraform.io/docs/commands/index.html Terraform commands
|
25
|
-
module ::Kitchen::Terraform::Client::Command
|
26
|
-
extend ::Dry::Monads::Either::Mixin
|
27
|
-
|
28
|
-
extend ::Dry::Monads::Try::Mixin
|
29
|
-
|
30
|
-
# Creates the apply command shell out.
|
31
|
-
#
|
32
|
-
# @param options [::Kitchen::Terraform::Client::Options] options for the command.
|
33
|
-
# @param working_directory[::String] the path to the directory in which to run the shell out.
|
34
|
-
# @return [::Dry::Monads::Either] the result of creating the shell out.
|
35
|
-
# @see https://www.terraform.io/docs/commands/apply.html Terraform Command: apply
|
36
|
-
def self.apply(options:, working_directory:)
|
37
|
-
create(
|
38
|
-
options: options,
|
39
|
-
subcommand: "apply",
|
40
|
-
working_directory: working_directory
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# Creates the destroy command shell out.
|
46
|
-
#
|
47
|
-
# @param options [::Kitchen::Terraform::Client::Options] options for the command.
|
48
|
-
# @param working_directory[::String] the path to the directory in which to run the shell out.
|
49
|
-
# @return [::Dry::Monads::Either] the result of creating the shell out.
|
50
|
-
# @see https://www.terraform.io/docs/commands/destroy.html Terraform Command: destroy
|
51
|
-
def self.destroy(options:, working_directory:)
|
52
|
-
create(
|
53
|
-
options: options,
|
54
|
-
subcommand: "destroy",
|
55
|
-
working_directory: working_directory
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
# Creates the init command shell out.
|
60
|
-
#
|
61
|
-
# @param options [::Kitchen::Terraform::Client::Options] options for the command.
|
62
|
-
# @param working_directory[::String] the path to the directory in which to run the shell out.
|
63
|
-
# @return [::Dry::Monads::Either] the result of creating the shell out.
|
64
|
-
# @see https://www.terraform.io/docs/commands/destroy.html Terraform Command: init
|
65
|
-
def self.init(options:, working_directory:)
|
66
|
-
create(
|
67
|
-
options: options,
|
68
|
-
subcommand: "init",
|
69
|
-
working_directory: working_directory
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
|
-
# Creates the output command shell out.
|
74
|
-
#
|
75
|
-
# @param options [::Kitchen::Terraform::Client::Options] options for the command.
|
76
|
-
# @param working_directory[::String] the path to the directory in which to run the shell out.
|
77
|
-
# @return [::Dry::Monads::Either] the result of creating the shell out.
|
78
|
-
# @see https://www.terraform.io/docs/commands/destroy.html Terraform Command: output
|
79
|
-
def self.output(options:, working_directory:)
|
80
|
-
create(
|
81
|
-
options: options,
|
82
|
-
subcommand: "output",
|
83
|
-
working_directory: working_directory
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Runs a command shell out.
|
88
|
-
#
|
89
|
-
# @param logger [::Kitchen::Logger, ::Terraform::DebugLogger] a logger to capture the run output of the command.
|
90
|
-
# @param shell_out [::Mixlib::ShellOut] the shell out to run.
|
91
|
-
# @param timeout [::Integer] the number of seconds to wait for the command to finish.
|
92
|
-
# @return [::Dry::Monads::Either] the result of running the shell out.
|
93
|
-
def self.run(logger:, shell_out:, timeout:)
|
94
|
-
try_to_run(
|
95
|
-
logger: logger,
|
96
|
-
shell_out: shell_out,
|
97
|
-
timeout: timeout
|
98
|
-
)
|
99
|
-
.bind do
|
100
|
-
Right shell_out.stdout
|
101
|
-
end
|
102
|
-
.or do |error|
|
103
|
-
Left error.to_s
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# Creates the validate command shell out.
|
108
|
-
#
|
109
|
-
# @param options [::Kitchen::Terraform::Client::Options] options for the command.
|
110
|
-
# @param working_directory[::String] the path to the directory in which to run the shell out.
|
111
|
-
# @return [::Dry::Monads::Either] the result of creating the shell out.
|
112
|
-
# @see https://www.terraform.io/docs/commands/destroy.html Terraform Command: validate
|
113
|
-
def self.validate(options:, working_directory:)
|
114
|
-
create(
|
115
|
-
options: options,
|
116
|
-
subcommand: "validate",
|
117
|
-
working_directory: working_directory
|
118
|
-
)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Creates the version command shell out.
|
122
|
-
#
|
123
|
-
# @param options [::Kitchen::Terraform::Client::Options] options for the command.
|
124
|
-
# @param working_directory[::String] the path to the directory in which to run the shell out.
|
125
|
-
# @return [::Dry::Monads::Either] the result of creating the shell out.
|
126
|
-
# @see https://www.terraform.io/docs/commands/destroy.html Terraform Command: version
|
127
|
-
def self.version(options: ::Kitchen::Terraform::Client::Options, working_directory:)
|
128
|
-
create(
|
129
|
-
options: options,
|
130
|
-
subcommand: "version",
|
131
|
-
working_directory: working_directory
|
132
|
-
)
|
133
|
-
end
|
134
|
-
|
135
|
-
private_class_method
|
136
|
-
|
137
|
-
# @api private
|
138
|
-
# @param options [::Kitchen::Terraform::Client::Options] options for the command.
|
139
|
-
# @param subcommand [::String] the subcommand to run through shell out.
|
140
|
-
# @param working_directory [::String] the path to the directory in which to run the shell out.
|
141
|
-
def self.create(options:, subcommand:, working_directory:)
|
142
|
-
Try ::Mixlib::ShellOut::InvalidCommandOption do
|
143
|
-
::Mixlib::ShellOut.new(
|
144
|
-
"terraform #{subcommand} #{options}".strip,
|
145
|
-
cwd: working_directory
|
146
|
-
)
|
147
|
-
end
|
148
|
-
.to_either
|
149
|
-
.or do |error|
|
150
|
-
Left "Failed to create `terraform #{subcommand}`: #{error}"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def self.try_to_run(logger:, shell_out:, timeout:)
|
155
|
-
Try(
|
156
|
-
::Errno::EACCES,
|
157
|
-
::Errno::ENOENT,
|
158
|
-
::Mixlib::ShellOut::CommandTimeout,
|
159
|
-
::Mixlib::ShellOut::ShellCommandFailed
|
160
|
-
) do
|
161
|
-
shell_out.live_stream = logger
|
162
|
-
shell_out.timeout = timeout
|
163
|
-
shell_out.run_command
|
164
|
-
shell_out.error!
|
165
|
-
end
|
166
|
-
.to_either
|
167
|
-
end
|
168
|
-
end
|