kitchen-terraform 5.7.1 → 6.1.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/README.md +21 -19
- data/lib/kitchen/driver/terraform.rb +1 -1
- data/lib/kitchen/provisioner/terraform.rb +1 -1
- data/lib/kitchen/terraform/breaking.rb +1 -1
- data/lib/kitchen/terraform/command/apply.rb +1 -1
- data/lib/kitchen/terraform/command/destroy.rb +1 -1
- data/lib/kitchen/terraform/command/get.rb +1 -1
- data/lib/kitchen/terraform/command/init/post_zero_fifteen_zero.rb +89 -0
- data/lib/kitchen/terraform/command/init/pre_zero_fifteen_zero.rb +101 -0
- data/lib/kitchen/terraform/command/init.rb +3 -80
- data/lib/kitchen/terraform/command/init_factory.rb +52 -0
- data/lib/kitchen/terraform/command/output.rb +1 -1
- data/lib/kitchen/terraform/command/validate/post_zero_fifteen_zero.rb +51 -0
- data/lib/kitchen/terraform/command/validate/pre_zero_fifteen_zero.rb +65 -0
- data/lib/kitchen/terraform/command/validate.rb +3 -41
- data/lib/kitchen/terraform/command/validate_factory.rb +54 -0
- data/lib/kitchen/terraform/command/version.rb +1 -1
- data/lib/kitchen/terraform/command/workspace_delete.rb +1 -1
- data/lib/kitchen/terraform/command/workspace_new.rb +1 -1
- data/lib/kitchen/terraform/command/workspace_select.rb +1 -1
- data/lib/kitchen/terraform/command.rb +1 -1
- data/lib/kitchen/terraform/command_executor.rb +3 -5
- data/lib/kitchen/terraform/command_flag/backend_config.rb +1 -1
- data/lib/kitchen/terraform/command_flag/color.rb +1 -1
- data/lib/kitchen/terraform/command_flag/lock_timeout.rb +1 -1
- data/lib/kitchen/terraform/command_flag/plugin_dir.rb +1 -1
- data/lib/kitchen/terraform/command_flag/upgrade.rb +2 -2
- data/lib/kitchen/terraform/command_flag/var.rb +1 -1
- data/lib/kitchen/terraform/command_flag/var_file.rb +1 -1
- data/lib/kitchen/terraform/command_flag.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/client.rb +3 -3
- data/lib/kitchen/terraform/config_attribute/color.rb +3 -3
- data/lib/kitchen/terraform/config_attribute/command_timeout.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/fail_fast.rb +3 -3
- data/lib/kitchen/terraform/config_attribute/lock.rb +3 -3
- 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 +3 -3
- data/lib/kitchen/terraform/config_attribute/systems.rb +552 -4
- data/lib/kitchen/terraform/config_attribute/variable_files.rb +3 -3
- data/lib/kitchen/terraform/config_attribute/variables.rb +1 -1
- data/lib/kitchen/terraform/config_attribute/verify_version.rb +3 -3
- data/lib/kitchen/terraform/config_attribute.rb +1 -1
- data/lib/kitchen/terraform/config_attribute_cacher.rb +1 -1
- data/lib/kitchen/terraform/config_attribute_contract/array_of_strings.rb +30 -0
- data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/boolean.rb +7 -11
- data/lib/kitchen/terraform/config_attribute_contract/hash_of_symbols_and_strings.rb +41 -0
- data/lib/kitchen/terraform/{config_schemas.rb → config_attribute_contract/integer.rb} +10 -3
- data/lib/kitchen/terraform/config_attribute_contract/optional_string.rb +30 -0
- data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/string.rb +7 -9
- data/lib/kitchen/terraform/config_attribute_contract/systems.rb +63 -0
- data/lib/kitchen/terraform/{config_predicates.rb → config_attribute_contract.rb} +3 -3
- data/lib/kitchen/terraform/config_attribute_definer.rb +2 -2
- data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +9 -16
- data/lib/kitchen/terraform/config_attribute_type/integer.rb +27 -23
- data/lib/kitchen/terraform/config_attribute_type.rb +1 -1
- data/lib/kitchen/terraform/configurable.rb +2 -2
- data/lib/kitchen/terraform/debug_logger.rb +1 -1
- data/lib/kitchen/terraform/deprecating.rb +1 -1
- data/lib/kitchen/terraform/driver/create.rb +39 -16
- data/lib/kitchen/terraform/driver/destroy.rb +53 -21
- data/lib/kitchen/terraform/driver.rb +1 -1
- data/lib/kitchen/terraform/error.rb +1 -1
- data/lib/kitchen/terraform/file_path_config_attribute_definer.rb +1 -1
- data/lib/kitchen/terraform/inspec/fail_fast_with_hosts.rb +1 -1
- data/lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb +1 -1
- data/lib/kitchen/terraform/inspec/without_hosts.rb +1 -1
- data/lib/kitchen/terraform/inspec.rb +1 -1
- data/lib/kitchen/terraform/inspec_factory.rb +1 -1
- data/lib/kitchen/terraform/inspec_options_factory.rb +1 -1
- data/lib/kitchen/terraform/inspec_runner.rb +5 -4
- data/lib/kitchen/terraform/outputs_manager.rb +1 -1
- data/lib/kitchen/terraform/outputs_parser.rb +1 -1
- data/lib/kitchen/terraform/outputs_reader.rb +2 -2
- data/lib/kitchen/terraform/provisioner/converge.rb +52 -25
- data/lib/kitchen/terraform/provisioner.rb +1 -1
- data/lib/kitchen/terraform/raise/action_failed.rb +1 -1
- data/lib/kitchen/terraform/raise/client_error.rb +1 -1
- data/lib/kitchen/terraform/raise.rb +1 -1
- data/lib/kitchen/terraform/shell_out.rb +6 -5
- data/lib/kitchen/terraform/system.rb +1 -1
- data/lib/kitchen/terraform/system_attrs_inputs_resolver.rb +1 -1
- data/lib/kitchen/terraform/system_attrs_outputs_resolver.rb +1 -1
- data/lib/kitchen/terraform/system_bastion_host_resolver.rb +1 -1
- data/lib/kitchen/terraform/system_hosts_resolver.rb +1 -1
- data/lib/kitchen/terraform/system_inspec_map.rb +1 -1
- data/lib/kitchen/terraform/systems_verifier/fail_fast.rb +1 -1
- data/lib/kitchen/terraform/systems_verifier/fail_slow.rb +1 -1
- data/lib/kitchen/terraform/systems_verifier.rb +1 -1
- data/lib/kitchen/terraform/systems_verifier_factory.rb +1 -1
- data/lib/kitchen/terraform/unsupported_client_version_error.rb +1 -1
- data/lib/kitchen/terraform/variables_manager.rb +1 -1
- data/lib/kitchen/terraform/verify_version.rb +5 -17
- data/lib/kitchen/terraform/verify_version_rescue_strategy/permissive.rb +1 -1
- data/lib/kitchen/terraform/verify_version_rescue_strategy/strict.rb +1 -1
- data/lib/kitchen/terraform/verify_version_rescue_strategy.rb +1 -1
- data/lib/kitchen/terraform/verify_version_rescue_strategy_factory.rb +1 -1
- data/lib/kitchen/terraform/version.rb +2 -2
- data/lib/kitchen/terraform/version_verifier.rb +1 -1
- data/lib/kitchen/terraform/version_verifier_strategy/supported.rb +1 -1
- data/lib/kitchen/terraform/version_verifier_strategy/unsupported.rb +1 -1
- data/lib/kitchen/terraform/version_verifier_strategy.rb +1 -1
- data/lib/kitchen/terraform/version_verifier_strategy_factory.rb +1 -1
- data/lib/kitchen/terraform.rb +1 -1
- data/lib/kitchen/verifier/terraform.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +65 -62
- metadata.gz.sig +0 -0
- data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +0 -81
- data/lib/kitchen/terraform/config_schemas/array_of_strings.rb +0 -38
- data/lib/kitchen/terraform/config_schemas/optional_string.rb +0 -38
- data/lib/kitchen/terraform/config_schemas/system.rb +0 -609
- data/lib/kitchen/terraform/config_schemas/systems.rb +0 -37
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -18,16 +18,12 @@ require "dry/validation"
|
|
18
18
|
|
19
19
|
module Kitchen
|
20
20
|
module Terraform
|
21
|
-
module
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end.dup
|
28
|
-
|
29
|
-
Boolean.define_singleton_method :to_s do
|
30
|
-
"Kitchen::Terraform::ConfigSchemas::Boolean"
|
21
|
+
module ConfigAttributeContract
|
22
|
+
# Boolean is the class of objects that provide a configuration attribute contract for a boolean.
|
23
|
+
class Boolean < ::Dry::Validation::Contract
|
24
|
+
schema do
|
25
|
+
required(:value).filled :bool?
|
26
|
+
end
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
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/validation"
|
18
|
+
|
19
|
+
module Kitchen
|
20
|
+
module Terraform
|
21
|
+
module ConfigAttributeContract
|
22
|
+
# HashOfSymbolsAndStrings is the class of objects that provide a configuration attribute contract for a hash
|
23
|
+
# including only symbol keys and string values.
|
24
|
+
class HashOfSymbolsAndStrings < ::Dry::Validation::Contract
|
25
|
+
schema do
|
26
|
+
required(:value).hash
|
27
|
+
end
|
28
|
+
|
29
|
+
rule :value do
|
30
|
+
value.each_pair do |symbol, string|
|
31
|
+
if ::Symbol != symbol.class
|
32
|
+
key.failure "the key of the key-value pair '#{symbol} => #{string}' must be a scalar"
|
33
|
+
elsif ::String != string.class
|
34
|
+
key.failure "the value of the key-value pair '#{symbol} => #{string}' must be a scalar"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -14,10 +14,17 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
+
require "dry/validation"
|
18
|
+
|
17
19
|
module Kitchen
|
18
20
|
module Terraform
|
19
|
-
|
20
|
-
|
21
|
+
module ConfigAttributeContract
|
22
|
+
# Integer is the class of objects that provide a configuration attribute contract for an integer.
|
23
|
+
class Integer < ::Dry::Validation::Contract
|
24
|
+
schema do
|
25
|
+
required(:value).value :int?
|
26
|
+
end
|
27
|
+
end
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
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/validation"
|
18
|
+
|
19
|
+
module Kitchen
|
20
|
+
module Terraform
|
21
|
+
module ConfigAttributeContract
|
22
|
+
# OptionalString is the class of objects that provide a configuration attribute contract for an optional string.
|
23
|
+
class OptionalString < ::Dry::Validation::Contract
|
24
|
+
schema do
|
25
|
+
required(:value).maybe :filled?, :str?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -18,14 +18,12 @@ require "dry/validation"
|
|
18
18
|
|
19
19
|
module Kitchen
|
20
20
|
module Terraform
|
21
|
-
module
|
22
|
-
#
|
23
|
-
String
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
String.define_singleton_method :to_s do
|
28
|
-
"Kitchen::Terraform::ConfigSchemas::String"
|
21
|
+
module ConfigAttributeContract
|
22
|
+
# String is the class of objects that provide a configuration attribute contract for a string.
|
23
|
+
class String < ::Dry::Validation::Contract
|
24
|
+
schema do
|
25
|
+
required(:value).filled :str?
|
26
|
+
end
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
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/validation"
|
18
|
+
|
19
|
+
module Kitchen
|
20
|
+
module Terraform
|
21
|
+
module ConfigAttributeContract
|
22
|
+
# Systems is the class of objects that provide a configuration attribute contract for systems.
|
23
|
+
class Systems < ::Dry::Validation::Contract
|
24
|
+
schema do
|
25
|
+
required(:value).array(:hash) do
|
26
|
+
required(:name).filled :str?
|
27
|
+
required(:backend).filled :str?
|
28
|
+
optional(:attrs).array(:filled?, :str?)
|
29
|
+
optional(:attrs_outputs).filled :hash?
|
30
|
+
optional(:backend_cache).value :bool?
|
31
|
+
optional(:bastion_host).filled :str?
|
32
|
+
optional(:bastion_host_output).filled :str?
|
33
|
+
optional(:bastion_port).value :int?
|
34
|
+
optional(:bastion_user).filled :str?
|
35
|
+
optional(:controls).array(:filled?, :str?)
|
36
|
+
optional(:enable_password).filled :str?
|
37
|
+
optional(:hosts).array :filled?, :str?
|
38
|
+
optional(:hosts_output).filled :str?
|
39
|
+
optional(:key_files).array(:filled?, :str?)
|
40
|
+
optional(:password).filled :str?
|
41
|
+
optional(:path).filled :str?
|
42
|
+
optional(:port).value :int?
|
43
|
+
optional(:profile_locations).array :filled?, :str?
|
44
|
+
optional(:proxy_command).filled :str?
|
45
|
+
optional(:reporter).array(:filled?, :str?)
|
46
|
+
optional(:self_signed).value :bool?
|
47
|
+
optional(:shell).value :bool?
|
48
|
+
optional(:shell_command).filled :str?
|
49
|
+
optional(:shell_options).filled :str?
|
50
|
+
optional(:show_progress).value :bool?
|
51
|
+
optional(:ssl).value :bool?
|
52
|
+
optional(:sudo).value :bool?
|
53
|
+
optional(:sudo_command).filled :str?
|
54
|
+
optional(:sudo_options).filled :str?
|
55
|
+
optional(:sudo_password).filled :str?
|
56
|
+
optional(:user).filled :str?
|
57
|
+
optional(:vendor_cache).filled :str?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -16,8 +16,8 @@
|
|
16
16
|
|
17
17
|
module Kitchen
|
18
18
|
module Terraform
|
19
|
-
#
|
20
|
-
module
|
19
|
+
# ConfigAttributeContract is the namespace for configuration attribute contracts.
|
20
|
+
module ConfigAttributeContract
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -24,7 +24,7 @@ module Kitchen
|
|
24
24
|
# @return [self]
|
25
25
|
def define(plugin_class:)
|
26
26
|
plugin_class.required_config attribute do |_attribute, value, _plugin|
|
27
|
-
process messages: schema.call(value: value).
|
27
|
+
process messages: schema.call(value: value).errors.to_h, plugin_class: plugin_class
|
28
28
|
end
|
29
29
|
plugin_class.default_config attribute do |plugin|
|
30
30
|
plugin.send "config_#{attribute}_default_value"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -16,13 +16,13 @@
|
|
16
16
|
|
17
17
|
require "dry/validation"
|
18
18
|
require "kitchen/terraform/config_attribute"
|
19
|
-
require "kitchen/terraform/
|
19
|
+
require "kitchen/terraform/config_attribute_contract/hash_of_symbols_and_strings"
|
20
20
|
|
21
21
|
module Kitchen
|
22
22
|
module Terraform
|
23
23
|
module ConfigAttributeType
|
24
|
-
# This modules applies the behaviour of a configuration attribute of type hash of symbols and strings to a module
|
25
|
-
# must be included by a plugin class.
|
24
|
+
# This modules applies the behaviour of a configuration attribute of type hash of symbols and strings to a module
|
25
|
+
# which must be included by a plugin class.
|
26
26
|
#
|
27
27
|
# @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
|
28
28
|
module HashOfSymbolsAndStrings
|
@@ -33,18 +33,11 @@ module Kitchen
|
|
33
33
|
# @param default_value [Proc] a proc which returns the default value.
|
34
34
|
# @return [self]
|
35
35
|
def self.apply(attribute:, config_attribute:, default_value:)
|
36
|
-
::Kitchen::Terraform::ConfigAttribute
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
.Schema do
|
42
|
-
configure do
|
43
|
-
extend ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
|
44
|
-
end
|
45
|
-
required(:value).value :hash_of_symbols_and_strings?
|
46
|
-
end,
|
47
|
-
).apply config_attribute: config_attribute
|
36
|
+
::Kitchen::Terraform::ConfigAttribute.new(
|
37
|
+
attribute: attribute,
|
38
|
+
default_value: default_value,
|
39
|
+
schema: ::Kitchen::Terraform::ConfigAttributeContract::HashOfSymbolsAndStrings.new,
|
40
|
+
).apply config_attribute: config_attribute
|
48
41
|
|
49
42
|
self
|
50
43
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -16,30 +16,34 @@
|
|
16
16
|
|
17
17
|
require "dry/validation"
|
18
18
|
require "kitchen/terraform/config_attribute"
|
19
|
+
require "kitchen/terraform/config_attribute_contract/integer"
|
19
20
|
require "kitchen/terraform/config_attribute_type"
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
attribute:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
22
|
+
module Kitchen
|
23
|
+
module Terraform
|
24
|
+
module ConfigAttributeType
|
25
|
+
# This module applies the behaviour of a configuration attribute of type integer to a module which must be
|
26
|
+
# included by a plugin class.
|
27
|
+
#
|
28
|
+
# @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
|
29
|
+
module Integer
|
30
|
+
# This method applies the configuration attribute behaviour to a module.
|
31
|
+
#
|
32
|
+
# @param attribute [Symbol] the symbol corresponding to the configuration attribute.
|
33
|
+
# @param config_attribute [Module] a module.
|
34
|
+
# @param default_value [Proc] a proc which returns the default value.
|
35
|
+
# @return [self]
|
36
|
+
def self.apply(attribute:, config_attribute:, default_value:)
|
37
|
+
::Kitchen::Terraform::ConfigAttribute
|
38
|
+
.new(
|
39
|
+
attribute: attribute,
|
40
|
+
default_value: default_value,
|
41
|
+
schema: ::Kitchen::Terraform::ConfigAttributeContract::Integer.new,
|
42
|
+
).apply config_attribute: config_attribute
|
42
43
|
|
43
|
-
|
44
|
+
self
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
44
48
|
end
|
45
49
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -42,7 +42,7 @@ module Kitchen
|
|
42
42
|
# @see Kitchen::Configurable#finalize_config!
|
43
43
|
def finalize_config!(instance)
|
44
44
|
super instance
|
45
|
-
self.version_requirement = ::Gem::Requirement.new ">= 0.11.4", "< 0.
|
45
|
+
self.version_requirement = ::Gem::Requirement.new ">= 0.11.4", "< 2.0.0"
|
46
46
|
self.workspace_name = "kitchen-terraform-#{::Shellwords.escape instance.name}"
|
47
47
|
end
|
48
48
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016-
|
3
|
+
# Copyright 2016-2021 Copado NCS LLC
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -15,12 +15,13 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require "kitchen"
|
18
|
-
require "kitchen/terraform/command/
|
18
|
+
require "kitchen/terraform/command/init_factory"
|
19
19
|
require "kitchen/terraform/command/version"
|
20
20
|
require "kitchen/terraform/command/workspace_new"
|
21
21
|
require "kitchen/terraform/command/workspace_select"
|
22
22
|
require "kitchen/terraform/command_executor"
|
23
23
|
require "kitchen/terraform/verify_version"
|
24
|
+
require "rubygems"
|
24
25
|
|
25
26
|
module Kitchen
|
26
27
|
module Terraform
|
@@ -29,7 +30,13 @@ module Kitchen
|
|
29
30
|
#
|
30
31
|
# ===== Initializing the Terraform Working Directory
|
31
32
|
#
|
32
|
-
#
|
33
|
+
# ====== Terraform >= 0.15.0
|
34
|
+
#
|
35
|
+
# {include:Kitchen::Terraform::Command::Init::PostZeroFifteenZero}
|
36
|
+
#
|
37
|
+
# ====== Terraform < 0.15.0
|
38
|
+
#
|
39
|
+
# {include:Kitchen::Terraform::Command::Init::PreZeroFifteenZero}
|
33
40
|
#
|
34
41
|
# ===== Creating or Selecting the Test Terraform Workspace
|
35
42
|
#
|
@@ -42,7 +49,8 @@ module Kitchen
|
|
42
49
|
# @raise [Kitchen::TransientFailure] if a command fails.
|
43
50
|
# @return [self]
|
44
51
|
def call
|
45
|
-
|
52
|
+
read_client_version
|
53
|
+
verify_version.call version: client_version
|
46
54
|
initialize_directory
|
47
55
|
create_or_select_workspace
|
48
56
|
|
@@ -58,20 +66,22 @@ module Kitchen
|
|
58
66
|
# @option config [String] :client the pathname of the Terraform client.
|
59
67
|
# @return [Kitchen::Terraform::Driver::Create]
|
60
68
|
def initialize(config:, logger:, version_requirement:, workspace_name:)
|
61
|
-
|
69
|
+
self.complete_config = config.to_hash.merge upgrade_during_init: true, workspace_name: workspace_name
|
70
|
+
self.client_version = ::Gem::Version.new "0.0.0"
|
62
71
|
self.command_executor = ::Kitchen::Terraform::CommandExecutor.new(
|
63
|
-
client:
|
72
|
+
client: complete_config.fetch(:client),
|
64
73
|
logger: logger,
|
65
74
|
)
|
66
|
-
self.init = ::Kitchen::Terraform::Command::Init.new config: hash_config
|
67
75
|
self.logger = logger
|
68
|
-
self.options = {
|
76
|
+
self.options = {
|
77
|
+
cwd: complete_config.fetch(:root_module_directory),
|
78
|
+
timeout: complete_config.fetch(:command_timeout),
|
79
|
+
}
|
69
80
|
self.workspace_name = workspace_name
|
70
|
-
self.workspace_new = ::Kitchen::Terraform::Command::WorkspaceNew.new config:
|
71
|
-
self.workspace_select = ::Kitchen::Terraform::Command::WorkspaceSelect.new config:
|
81
|
+
self.workspace_new = ::Kitchen::Terraform::Command::WorkspaceNew.new config: complete_config
|
82
|
+
self.workspace_select = ::Kitchen::Terraform::Command::WorkspaceSelect.new config: complete_config
|
72
83
|
self.verify_version = ::Kitchen::Terraform::VerifyVersion.new(
|
73
|
-
|
74
|
-
config: config,
|
84
|
+
config: complete_config,
|
75
85
|
logger: logger,
|
76
86
|
version_requirement: version_requirement,
|
77
87
|
)
|
@@ -81,8 +91,9 @@ module Kitchen
|
|
81
91
|
private
|
82
92
|
|
83
93
|
attr_accessor(
|
94
|
+
:client_version,
|
84
95
|
:command_executor,
|
85
|
-
:
|
96
|
+
:complete_config,
|
86
97
|
:logger,
|
87
98
|
:options,
|
88
99
|
:verify_version,
|
@@ -94,7 +105,7 @@ module Kitchen
|
|
94
105
|
|
95
106
|
def create_or_select_workspace
|
96
107
|
logger.warn "Creating the #{workspace_name} Terraform workspace..."
|
97
|
-
command_executor.run command: workspace_new, options: options do |standard_output
|
108
|
+
command_executor.run command: workspace_new, options: options do |standard_output|
|
98
109
|
end
|
99
110
|
logger.warn "Finished creating the #{workspace_name} Terraform workspace."
|
100
111
|
rescue ::Kitchen::TransientFailure
|
@@ -103,14 +114,26 @@ module Kitchen
|
|
103
114
|
|
104
115
|
def initialize_directory
|
105
116
|
logger.warn "Initializing the Terraform working directory..."
|
106
|
-
command_executor.run
|
117
|
+
command_executor.run(
|
118
|
+
command: ::Kitchen::Terraform::Command::InitFactory.new(version: client_version)
|
119
|
+
.build(config: complete_config),
|
120
|
+
options: options,
|
121
|
+
) do |standard_output|
|
107
122
|
end
|
108
123
|
logger.warn "Finished initializing the Terraform working directory."
|
109
124
|
end
|
110
125
|
|
126
|
+
def read_client_version
|
127
|
+
logger.warn "Reading the Terraform client version..."
|
128
|
+
command_executor.run command: version, options: options do |standard_output|
|
129
|
+
self.client_version = ::Gem::Version.new standard_output.slice /Terraform v(\d+\.\d+\.\d+)/, 1
|
130
|
+
end
|
131
|
+
logger.warn "Finished reading the Terraform client version."
|
132
|
+
end
|
133
|
+
|
111
134
|
def select_workspace
|
112
135
|
logger.warn "Selecting the #{workspace_name} Terraform workspace..."
|
113
|
-
command_executor.run command: workspace_select, options: options do |standard_output
|
136
|
+
command_executor.run command: workspace_select, options: options do |standard_output|
|
114
137
|
end
|
115
138
|
logger.warn "Finished selecting the #{workspace_name} Terraform workspace."
|
116
139
|
end
|