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
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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.
|
@@ -39,6 +39,11 @@ module Kitchen
|
|
39
39
|
# Example:: <code>client: terraform</code>
|
40
40
|
module Client
|
41
41
|
class << self
|
42
|
+
# .included is a callback to define the configuration attribute which is invoked when this module is included
|
43
|
+
# in a plugin class.
|
44
|
+
#
|
45
|
+
# @param plugin_class [Kitchen::Configurable] A plugin class.
|
46
|
+
# @return [self]
|
42
47
|
def included(plugin_class)
|
43
48
|
::Kitchen::Terraform::ConfigAttributeDefiner.new(
|
44
49
|
attribute: self,
|
@@ -47,9 +52,11 @@ module Kitchen
|
|
47
52
|
plugin_class.expand_path_for to_sym do |plugin|
|
48
53
|
!::TTY::Which.exist? plugin[to_sym]
|
49
54
|
end
|
55
|
+
|
56
|
+
self
|
50
57
|
end
|
51
58
|
|
52
|
-
# @return [
|
59
|
+
# @return [Symbol] the symbol corresponding to this attribute.
|
53
60
|
def to_sym
|
54
61
|
:client
|
55
62
|
end
|
@@ -57,7 +64,7 @@ module Kitchen
|
|
57
64
|
|
58
65
|
extend ::Kitchen::Terraform::ConfigAttributeCacher
|
59
66
|
|
60
|
-
# @return [
|
67
|
+
# @return [String] </code>"terraform"</code>
|
61
68
|
def config_client_default_value
|
62
69
|
"terraform"
|
63
70
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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.
|
@@ -36,7 +36,7 @@ module Kitchen
|
|
36
36
|
# A callback to define the configuration attribute which is invoked when this module is included in a plugin
|
37
37
|
# class.
|
38
38
|
#
|
39
|
-
# @param plugin_class [
|
39
|
+
# @param plugin_class [Kitchen::Configurable] A plugin class.
|
40
40
|
# @return [void]
|
41
41
|
def included(plugin_class)
|
42
42
|
::Kitchen::Terraform::FilePathConfigAttributeDefiner.new(
|
@@ -45,7 +45,7 @@ module Kitchen
|
|
45
45
|
).define plugin_class: plugin_class
|
46
46
|
end
|
47
47
|
|
48
|
-
# @return [
|
48
|
+
# @return [Symbol] the symbol corresponding to this attribute.
|
49
49
|
def to_sym
|
50
50
|
:plugin_directory
|
51
51
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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.
|
@@ -33,7 +33,7 @@ module Kitchen
|
|
33
33
|
# A callback to define the configuration attribute which is invoked when this module is included in a plugin
|
34
34
|
# class.
|
35
35
|
#
|
36
|
-
# @param plugin_class [
|
36
|
+
# @param plugin_class [Kitchen::Configurable] A plugin class.
|
37
37
|
# @return [void]
|
38
38
|
def included(plugin_class)
|
39
39
|
::Kitchen::Terraform::FilePathConfigAttributeDefiner.new(
|
@@ -42,7 +42,7 @@ module Kitchen
|
|
42
42
|
).define plugin_class: plugin_class
|
43
43
|
end
|
44
44
|
|
45
|
-
# @return [
|
45
|
+
# @return [Symbol] the symbol corresponding to the attribute.
|
46
46
|
def to_sym
|
47
47
|
:root_module_directory
|
48
48
|
end
|
@@ -50,7 +50,7 @@ module Kitchen
|
|
50
50
|
|
51
51
|
extend ::Kitchen::Terraform::ConfigAttributeCacher
|
52
52
|
|
53
|
-
# @return [
|
53
|
+
# @return [String] the working directory of the Test Kitchen process.
|
54
54
|
def config_root_module_directory_default_value
|
55
55
|
"."
|
56
56
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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.
|
@@ -37,7 +37,7 @@ module Kitchen
|
|
37
37
|
# A callback to define the configuration attribute which is invoked when this module is included in a plugin
|
38
38
|
# class.
|
39
39
|
#
|
40
|
-
# @param plugin_class [
|
40
|
+
# @param plugin_class [Kitchen::Configurable] A plugin class.
|
41
41
|
# @return [void]
|
42
42
|
def included(plugin_class)
|
43
43
|
::Kitchen::Terraform::FilePathConfigAttributeDefiner.new(
|
@@ -46,7 +46,7 @@ module Kitchen
|
|
46
46
|
).define plugin_class: plugin_class
|
47
47
|
end
|
48
48
|
|
49
|
-
# @return [
|
49
|
+
# @return [Symbol] the symbol corresponding to this attribute.
|
50
50
|
def to_sym
|
51
51
|
:variable_files
|
52
52
|
end
|
@@ -54,7 +54,7 @@ module Kitchen
|
|
54
54
|
|
55
55
|
extend ::Kitchen::Terraform::ConfigAttributeCacher
|
56
56
|
|
57
|
-
# @return [
|
57
|
+
# @return [Array] an empty array.
|
58
58
|
def config_variable_files_default_value
|
59
59
|
[]
|
60
60
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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.
|
@@ -21,7 +21,7 @@ require "kitchen/terraform/config_schemas/boolean"
|
|
21
21
|
module Kitchen
|
22
22
|
module Terraform
|
23
23
|
class ConfigAttribute
|
24
|
-
# This attribute toggles verification of support for the version of the Terraform client specified by the
|
24
|
+
# This attribute toggles strict or permissive verification of support for the version of the Terraform client specified by the
|
25
25
|
# <code>client</code> attribute.
|
26
26
|
#
|
27
27
|
# Type:: {http://www.yaml.org/spec/1.2/spec.html#id2803629 Boolean}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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,31 +14,33 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
|
17
|
+
module Kitchen
|
18
|
+
module Terraform
|
19
|
+
# Behaviour to cache configuration attribute lookups.
|
20
|
+
module ConfigAttributeCacher
|
21
|
+
# A callback to define an attribute lookup cache which is invoked when this module is extended by a
|
22
|
+
# configuration attribute.
|
23
|
+
#
|
24
|
+
# @param configuration_attribute [::Kitchen::Terraform::ConfigAttribute] a configuration attribute.
|
25
|
+
# @return [void]
|
26
|
+
def self.extended(configuration_attribute)
|
27
|
+
configuration_attribute.define_cache
|
28
|
+
end
|
18
29
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# @param attribute_name [::Symbol] the name of the attribute
|
34
|
-
def define_cache(attribute_name: to_sym)
|
35
|
-
define_method "config_#{attribute_name}" do
|
36
|
-
instance_variable_defined? "@config_#{attribute_name}" and
|
37
|
-
instance_variable_get "@config_#{attribute_name}" or
|
38
|
-
instance_variable_set(
|
39
|
-
"@config_#{attribute_name}",
|
40
|
-
config.fetch(attribute_name)
|
41
|
-
)
|
30
|
+
# Defines an instance method named "config_<attribute_name>" which caches the value of the configuration attribute
|
31
|
+
# lookup using an equivalently named instance variable.
|
32
|
+
#
|
33
|
+
# @param attribute_name [Symbol] the name of the attribute
|
34
|
+
def define_cache(attribute_name: to_sym)
|
35
|
+
define_method "config_#{attribute_name}" do
|
36
|
+
instance_variable_defined? "@config_#{attribute_name}" and
|
37
|
+
instance_variable_get "@config_#{attribute_name}" or
|
38
|
+
instance_variable_set(
|
39
|
+
"@config_#{attribute_name}",
|
40
|
+
config.fetch(attribute_name)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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,50 +14,44 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
class
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
.
|
31
|
-
|
32
|
-
)
|
33
|
-
end
|
34
|
-
plugin_class.default_config @attribute do |plugin|
|
35
|
-
plugin.send "config_#{@attribute}_default_value"
|
36
|
-
end
|
37
|
-
end
|
17
|
+
module Kitchen
|
18
|
+
module Terraform
|
19
|
+
# ConfigAttributeDefiner is the class of objects which define configuration attributes on a plugin class.
|
20
|
+
class ConfigAttributeDefiner
|
21
|
+
# #define defines a configuration attribute on a plugin class.
|
22
|
+
#
|
23
|
+
# @param plugin_class [Kitchen::Configurable] a plugin class.
|
24
|
+
# @return [self]
|
25
|
+
def define(plugin_class:)
|
26
|
+
plugin_class.required_config attribute do |_attribute, value, _plugin|
|
27
|
+
process messages: schema.call(value: value).messages, plugin_class: plugin_class
|
28
|
+
end
|
29
|
+
plugin_class.default_config attribute do |plugin|
|
30
|
+
plugin.send "config_#{attribute}_default_value"
|
31
|
+
end
|
38
32
|
|
39
|
-
|
33
|
+
self
|
34
|
+
end
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
36
|
+
# #initialize prepares a new instance of the class.
|
37
|
+
#
|
38
|
+
# @param attribute [Kitchen::Terraform::ConfigAttribute] an attribute to be defined on a plugin class.
|
39
|
+
# @param schema [Dry::Validation::Schema] a schema to use for validation of values of the attribute.
|
40
|
+
# @return [Kitchen::Terraform::ConfigAttributeDefined]
|
41
|
+
def initialize(attribute:, schema:)
|
42
|
+
self.attribute = attribute.to_sym
|
43
|
+
self.schema = schema
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
)
|
46
|
+
private
|
47
|
+
|
48
|
+
attr_accessor :attribute, :schema
|
49
|
+
|
50
|
+
def process(messages:, plugin_class:)
|
51
|
+
return if messages.empty?
|
52
|
+
|
53
|
+
raise ::Kitchen::UserError, "#{plugin_class} configuration: #{attribute} #{messages}"
|
54
|
+
end
|
55
|
+
end
|
62
56
|
end
|
63
57
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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,8 +14,10 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
# The namespace for configuration attribute types.
|
20
|
-
module
|
17
|
+
module Kitchen
|
18
|
+
module Terraform
|
19
|
+
# The namespace for configuration attribute types.
|
20
|
+
module ConfigAttributeType
|
21
|
+
end
|
22
|
+
end
|
21
23
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2016 New Context
|
3
|
+
# Copyright 2016-2019 New Context, Inc.
|
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,34 +16,39 @@
|
|
16
16
|
|
17
17
|
require "dry/validation"
|
18
18
|
require "kitchen/terraform/config_attribute"
|
19
|
-
require "kitchen/terraform/config_attribute_type"
|
20
19
|
require "kitchen/terraform/config_predicates/hash_of_symbols_and_strings"
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
attribute:
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
21
|
+
module Kitchen
|
22
|
+
module Terraform
|
23
|
+
module ConfigAttributeType
|
24
|
+
# This modules applies the behaviour of a configuration attribute of type hash of symbols and strings to a module which
|
25
|
+
# must be included by a plugin class.
|
26
|
+
#
|
27
|
+
# @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
|
28
|
+
module HashOfSymbolsAndStrings
|
29
|
+
# This method applies the configuration attribute behaviour to a module.
|
30
|
+
#
|
31
|
+
# @param attribute [Symbol] the symbol corresponding to the configuration attribute.
|
32
|
+
# @param config_attribute [Module] a module.
|
33
|
+
# @param default_value [Proc] a proc which returns the default value.
|
34
|
+
# @return [self]
|
35
|
+
def self.apply(attribute:, config_attribute:, default_value:)
|
36
|
+
::Kitchen::Terraform::ConfigAttribute
|
37
|
+
.new(
|
38
|
+
attribute: attribute,
|
39
|
+
default_value: default_value,
|
40
|
+
schema: ::Dry::Validation
|
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
|
46
48
|
|
47
|
-
|
49
|
+
self
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
48
53
|
end
|
49
54
|
end
|