kitchen-terraform 5.1.1 → 5.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +37 -173
- data/lib/kitchen/driver/terraform.rb +196 -514
- data/lib/kitchen/provisioner/terraform.rb +88 -86
- data/lib/kitchen/terraform.rb +5 -6
- data/lib/kitchen/terraform/breaking.rb +7 -5
- data/lib/kitchen/terraform/command.rb +7 -5
- data/lib/kitchen/terraform/command/apply.rb +87 -0
- data/lib/kitchen/terraform/command/destroy.rb +88 -0
- data/lib/kitchen/terraform/command/get.rb +32 -0
- data/lib/kitchen/terraform/command/init.rb +102 -0
- data/lib/kitchen/terraform/command/output.rb +11 -50
- data/lib/kitchen/terraform/command/validate.rb +63 -0
- data/lib/kitchen/terraform/command/version.rb +5 -42
- data/lib/kitchen/terraform/command/workspace_delete.rb +41 -0
- data/lib/kitchen/terraform/command/workspace_new.rb +43 -0
- data/lib/kitchen/terraform/command/workspace_select.rb +43 -0
- data/lib/kitchen/terraform/command_executor.rb +60 -0
- data/lib/kitchen/terraform/command_flag.rb +23 -0
- data/lib/kitchen/terraform/command_flag/backend_config.rb +43 -0
- data/lib/kitchen/terraform/command_flag/color.rb +45 -0
- data/lib/kitchen/terraform/command_flag/lock_timeout.rb +42 -0
- data/lib/kitchen/terraform/command_flag/plugin_dir.rb +47 -0
- data/lib/kitchen/terraform/command_flag/upgrade.rb +45 -0
- data/lib/kitchen/terraform/command_flag/var.rb +43 -0
- data/lib/kitchen/terraform/command_flag/var_file.rb +45 -0
- data/lib/kitchen/terraform/config_attribute.rb +58 -55
- data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/client.rb +10 -3
- data/lib/kitchen/terraform/config_attribute/color.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/command_timeout.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/fail_fast.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/lock.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/parallelism.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +3 -3
- data/lib/kitchen/terraform/config_attribute/root_module_directory.rb +4 -4
- data/lib/kitchen/terraform/config_attribute/systems.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/variable_files.rb +4 -4
- data/lib/kitchen/terraform/config_attribute/variables.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/verify_version.rb +2 -2
- data/lib/kitchen/terraform/config_attribute_cacher.rb +27 -25
- data/lib/kitchen/terraform/config_attribute_definer.rb +37 -43
- data/lib/kitchen/terraform/config_attribute_type.rb +7 -5
- data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +32 -27
- data/lib/kitchen/terraform/config_attribute_type/integer.rb +4 -4
- data/lib/kitchen/terraform/config_predicates.rb +7 -5
- data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +6 -6
- data/lib/kitchen/terraform/config_schemas.rb +7 -5
- data/lib/kitchen/terraform/config_schemas/array_of_strings.rb +20 -13
- data/lib/kitchen/terraform/config_schemas/boolean.rb +16 -9
- data/lib/kitchen/terraform/config_schemas/optional_string.rb +20 -13
- data/lib/kitchen/terraform/config_schemas/string.rb +13 -7
- data/lib/kitchen/terraform/config_schemas/system.rb +38 -16
- data/lib/kitchen/terraform/config_schemas/systems.rb +5 -2
- data/lib/kitchen/terraform/configurable.rb +41 -21
- data/lib/kitchen/terraform/debug_logger.rb +1 -1
- data/lib/kitchen/terraform/deprecating.rb +7 -5
- data/lib/kitchen/terraform/driver.rb +23 -0
- data/lib/kitchen/terraform/driver/create.rb +120 -0
- data/lib/kitchen/terraform/driver/destroy.rb +169 -0
- data/lib/kitchen/terraform/error.rb +7 -5
- data/lib/kitchen/terraform/file_path_config_attribute_definer.rb +30 -27
- data/lib/kitchen/terraform/inspec.rb +3 -57
- data/lib/kitchen/terraform/inspec/fail_fast_with_hosts.rb +59 -0
- data/lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb +69 -0
- data/lib/kitchen/terraform/inspec/without_hosts.rb +52 -0
- data/lib/kitchen/terraform/inspec_factory.rb +68 -0
- data/lib/kitchen/terraform/inspec_options_factory.rb +86 -0
- data/lib/kitchen/terraform/inspec_runner.rb +88 -0
- data/lib/kitchen/terraform/outputs_manager.rb +64 -0
- data/lib/kitchen/terraform/outputs_parser.rb +39 -0
- data/lib/kitchen/terraform/outputs_reader.rb +63 -0
- data/lib/kitchen/terraform/provisioner.rb +23 -0
- data/lib/kitchen/terraform/provisioner/converge.rb +206 -0
- data/lib/kitchen/terraform/raise.rb +23 -0
- data/lib/kitchen/terraform/raise/action_failed.rb +49 -0
- data/lib/kitchen/terraform/raise/client_error.rb +49 -0
- data/lib/kitchen/terraform/shell_out.rb +90 -59
- data/lib/kitchen/terraform/system.rb +63 -93
- data/lib/kitchen/terraform/system_attrs_inputs_resolver.rb +49 -0
- data/lib/kitchen/terraform/system_attrs_outputs_resolver.rb +80 -0
- data/lib/kitchen/terraform/system_bastion_host_resolver.rb +72 -0
- data/lib/kitchen/terraform/system_hosts_resolver.rb +39 -17
- data/lib/kitchen/terraform/system_inspec_map.rb +49 -0
- data/lib/kitchen/terraform/systems_verifier.rb +23 -0
- data/lib/kitchen/terraform/systems_verifier/fail_fast.rb +52 -0
- data/lib/kitchen/terraform/systems_verifier/fail_slow.rb +62 -0
- data/lib/kitchen/terraform/systems_verifier_factory.rb +50 -0
- data/lib/kitchen/terraform/unsupported_client_version_error.rb +26 -0
- data/lib/kitchen/terraform/variables_manager.rb +64 -0
- data/lib/kitchen/terraform/verify_version.rb +63 -20
- data/lib/kitchen/terraform/verify_version_rescue_strategy.rb +23 -0
- data/lib/kitchen/terraform/verify_version_rescue_strategy/permissive.rb +50 -0
- data/lib/kitchen/terraform/verify_version_rescue_strategy/strict.rb +47 -0
- data/lib/kitchen/terraform/verify_version_rescue_strategy_factory.rb +51 -0
- data/lib/kitchen/terraform/version.rb +59 -58
- data/lib/kitchen/terraform/version_verifier.rb +50 -0
- data/lib/kitchen/terraform/version_verifier_strategy.rb +25 -0
- data/lib/kitchen/terraform/version_verifier_strategy/supported.rb +33 -0
- data/lib/kitchen/terraform/version_verifier_strategy/unsupported.rb +34 -0
- data/lib/kitchen/terraform/version_verifier_strategy_factory.rb +50 -0
- data/lib/kitchen/verifier/terraform.rb +71 -62
- metadata +143 -80
- metadata.gz.sig +0 -0
- data/lib/kitchen/terraform/inspec_options_mapper.rb +0 -73
- data/lib/kitchen/terraform/inspec_with_hosts.rb +0 -50
- data/lib/kitchen/terraform/inspec_without_hosts.rb +0 -45
- data/lib/kitchen/terraform/system_attrs_resolver.rb +0 -60
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,73 +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 "kitchen/terraform"
|
18
|
-
|
19
|
-
# Kitchen::Terraform::InSpecOptionsMapper maps system configuration attributes to an InSpec options hash.
|
20
|
-
class ::Kitchen::Terraform::InSpecOptionsMapper
|
21
|
-
SYSTEM_ATTRIBUTES_TO_OPTIONS = {
|
22
|
-
attrs: :input_file,
|
23
|
-
backend_cache: :backend_cache,
|
24
|
-
backend: :backend,
|
25
|
-
bastion_host: :bastion_host,
|
26
|
-
bastion_port: :bastion_port,
|
27
|
-
bastion_user: :bastion_user,
|
28
|
-
controls: :controls,
|
29
|
-
enable_password: :enable_password,
|
30
|
-
key_files: :key_files,
|
31
|
-
password: :password,
|
32
|
-
path: :path,
|
33
|
-
port: :port,
|
34
|
-
proxy_command: :proxy_command,
|
35
|
-
reporter: "reporter",
|
36
|
-
self_signed: :self_signed,
|
37
|
-
shell_command: :shell_command,
|
38
|
-
shell_options: :shell_options,
|
39
|
-
shell: :shell,
|
40
|
-
show_progress: :show_progress,
|
41
|
-
ssl: :ssl,
|
42
|
-
sudo_command: :sudo_command,
|
43
|
-
sudo_options: :sudo_options,
|
44
|
-
sudo_password: :sudo_password,
|
45
|
-
sudo: :sudo,
|
46
|
-
user: :user,
|
47
|
-
vendor_cache: :vendor_cache,
|
48
|
-
}
|
49
|
-
|
50
|
-
# map populates an InSpec options hash based on the intersection between the system keys and the supported options
|
51
|
-
# keys, converting keys from symbols to strings as required by InSpec.
|
52
|
-
#
|
53
|
-
# @param options [::Hash] the InSpec options hash to be populated.
|
54
|
-
# @return [void]
|
55
|
-
def map(options:, system:)
|
56
|
-
system.lazy.select do |attribute_name, _|
|
57
|
-
system_attributes_to_options.key?(attribute_name)
|
58
|
-
end.each do |attribute_name, attribute_value|
|
59
|
-
options.store system_attributes_to_options.fetch(attribute_name), attribute_value
|
60
|
-
end
|
61
|
-
|
62
|
-
options
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
attr_accessor :system_attributes_to_options
|
68
|
-
|
69
|
-
# @api private
|
70
|
-
def initialize
|
71
|
-
self.system_attributes_to_options = ::Kitchen::Terraform::InSpecOptionsMapper::SYSTEM_ATTRIBUTES_TO_OPTIONS.dup
|
72
|
-
end
|
73
|
-
end
|
@@ -1,50 +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 "kitchen"
|
18
|
-
require "kitchen/terraform/error"
|
19
|
-
require "kitchen/terraform/inspec"
|
20
|
-
|
21
|
-
module Kitchen
|
22
|
-
module Terraform
|
23
|
-
# InSpec instances act as interfaces to the InSpec gem.
|
24
|
-
class InSpecWithHosts
|
25
|
-
# exec executes the InSpec controls of an InSpec profile.
|
26
|
-
#
|
27
|
-
# @raise [::Kitchen::Terraform::Error] if the execution of the InSpec controls fails.
|
28
|
-
# @return [void]
|
29
|
-
def exec(system:)
|
30
|
-
system.each_host do |host:|
|
31
|
-
::Kitchen::Terraform::InSpec
|
32
|
-
.new(options: options.merge(host: host), profile_locations: profile_locations)
|
33
|
-
.info(message: "#{system}: Verifying host #{host}").exec
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
attr_accessor :options, :profile_locations
|
40
|
-
|
41
|
-
# @param options [::Hash] options for execution.
|
42
|
-
# @param profile_locations [::Array<::String>] the locations of the InSpec profiles which contain the controls to
|
43
|
-
# be executed.
|
44
|
-
def initialize(options:, profile_locations:)
|
45
|
-
self.options = options
|
46
|
-
self.profile_locations = profile_locations
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,45 +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 "kitchen/terraform/inspec"
|
18
|
-
|
19
|
-
module Kitchen
|
20
|
-
module Terraform
|
21
|
-
# InSpec instances act as interfaces to the InSpec gem.
|
22
|
-
class InSpecWithoutHosts
|
23
|
-
# exec executes the InSpec controls of an InSpec profile.
|
24
|
-
#
|
25
|
-
# @raise [::Kitchen::Terraform::Error] if the execution of the InSpec controls fails.
|
26
|
-
# @return [void]
|
27
|
-
def exec(system:)
|
28
|
-
::Kitchen::Terraform::InSpec
|
29
|
-
.new(options: options, profile_locations: profile_locations).info(message: "#{system}: Verifying").exec
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
attr_accessor :options, :profile_locations
|
35
|
-
|
36
|
-
# @param options [::Hash] options for execution.
|
37
|
-
# @param profile_locations [::Array<::String>] the locations of the InSpec profiles which contain the controls to
|
38
|
-
# be executed.
|
39
|
-
def initialize(options:, profile_locations:)
|
40
|
-
self.options = options
|
41
|
-
self.profile_locations = profile_locations
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,60 +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 "kitchen/terraform"
|
18
|
-
require "kitchen/terraform/error"
|
19
|
-
|
20
|
-
module Kitchen
|
21
|
-
module Terraform
|
22
|
-
# SystemAttrsResolver is the class of objects which resolve for systems the attrs which are contained in outputs.
|
23
|
-
class SystemAttrsResolver
|
24
|
-
# #resolve resolves the attrs.
|
25
|
-
#
|
26
|
-
# @param attrs_outputs_keys [::Array<::String>] the names of the InSpec attributes.
|
27
|
-
# @param attrs_outputs_values [::Array<::String>] the names of the Terraform outputs.
|
28
|
-
# @param system [::Kitchen::Terraform::System] the system.
|
29
|
-
# @raise [::Kitchen::Terraform::Error] if the fetching the value of the output fails.
|
30
|
-
def resolve(attrs_outputs_keys:, attrs_outputs_values:, system:)
|
31
|
-
system.add_attrs(attrs: @inputs.merge(@outputs.merge(
|
32
|
-
attrs_outputs_keys.lazy.map(&:to_s).zip(@outputs.fetch_values(*attrs_outputs_values)).to_h
|
33
|
-
)))
|
34
|
-
|
35
|
-
self
|
36
|
-
rescue ::KeyError => key_error
|
37
|
-
raise ::Kitchen::Terraform::Error, "Resolving attrs failed\n#{key_error}"
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
# #initialize prepares the instance to be used.
|
43
|
-
#
|
44
|
-
# @param outputs [#to_hash] the outputs of the Terraform state under test.
|
45
|
-
def initialize(inputs:, outputs:)
|
46
|
-
@inputs = inputs.map do |key, value|
|
47
|
-
["input_#{key}", value]
|
48
|
-
end.to_h
|
49
|
-
@outputs = Hash[outputs].map do |key, value|
|
50
|
-
[key, value.fetch("value")]
|
51
|
-
end.to_h
|
52
|
-
@outputs.merge!(@outputs.map do |key, value|
|
53
|
-
["output_#{key}", value]
|
54
|
-
end.to_h)
|
55
|
-
rescue ::KeyError => key_error
|
56
|
-
raise ::Kitchen::Terraform::Error, "Preparing to resolve attrs failed\n#{key_error}"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|