kitchen-terraform 5.8.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +17 -16
  5. data/lib/kitchen/driver/terraform.rb +1 -1
  6. data/lib/kitchen/provisioner/terraform.rb +1 -1
  7. data/lib/kitchen/terraform.rb +1 -1
  8. data/lib/kitchen/terraform/breaking.rb +1 -1
  9. data/lib/kitchen/terraform/command.rb +1 -1
  10. data/lib/kitchen/terraform/command/apply.rb +1 -1
  11. data/lib/kitchen/terraform/command/destroy.rb +1 -1
  12. data/lib/kitchen/terraform/command/get.rb +1 -1
  13. data/lib/kitchen/terraform/command/init.rb +1 -1
  14. data/lib/kitchen/terraform/command/init/post_zero_fifteen_zero.rb +1 -1
  15. data/lib/kitchen/terraform/command/init/pre_zero_fifteen_zero.rb +1 -1
  16. data/lib/kitchen/terraform/command/init_factory.rb +1 -1
  17. data/lib/kitchen/terraform/command/output.rb +1 -1
  18. data/lib/kitchen/terraform/command/validate.rb +1 -1
  19. data/lib/kitchen/terraform/command/validate/post_zero_fifteen_zero.rb +1 -1
  20. data/lib/kitchen/terraform/command/validate/pre_zero_fifteen_zero.rb +1 -1
  21. data/lib/kitchen/terraform/command/validate_factory.rb +1 -1
  22. data/lib/kitchen/terraform/command/version.rb +1 -1
  23. data/lib/kitchen/terraform/command/workspace_delete.rb +1 -1
  24. data/lib/kitchen/terraform/command/workspace_new.rb +1 -1
  25. data/lib/kitchen/terraform/command/workspace_select.rb +1 -1
  26. data/lib/kitchen/terraform/command_executor.rb +3 -5
  27. data/lib/kitchen/terraform/command_flag.rb +1 -1
  28. data/lib/kitchen/terraform/command_flag/backend_config.rb +1 -1
  29. data/lib/kitchen/terraform/command_flag/color.rb +1 -1
  30. data/lib/kitchen/terraform/command_flag/lock_timeout.rb +1 -1
  31. data/lib/kitchen/terraform/command_flag/plugin_dir.rb +1 -1
  32. data/lib/kitchen/terraform/command_flag/upgrade.rb +1 -1
  33. data/lib/kitchen/terraform/command_flag/var.rb +1 -1
  34. data/lib/kitchen/terraform/command_flag/var_file.rb +1 -1
  35. data/lib/kitchen/terraform/config_attribute.rb +1 -1
  36. data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +1 -1
  37. data/lib/kitchen/terraform/config_attribute/client.rb +3 -3
  38. data/lib/kitchen/terraform/config_attribute/color.rb +3 -3
  39. data/lib/kitchen/terraform/config_attribute/command_timeout.rb +1 -1
  40. data/lib/kitchen/terraform/config_attribute/fail_fast.rb +3 -3
  41. data/lib/kitchen/terraform/config_attribute/lock.rb +3 -3
  42. data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +1 -1
  43. data/lib/kitchen/terraform/config_attribute/parallelism.rb +1 -1
  44. data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +3 -3
  45. data/lib/kitchen/terraform/config_attribute/root_module_directory.rb +3 -3
  46. data/lib/kitchen/terraform/config_attribute/systems.rb +552 -4
  47. data/lib/kitchen/terraform/config_attribute/variable_files.rb +3 -3
  48. data/lib/kitchen/terraform/config_attribute/variables.rb +1 -1
  49. data/lib/kitchen/terraform/config_attribute/verify_version.rb +3 -3
  50. data/lib/kitchen/terraform/config_attribute_cacher.rb +1 -1
  51. data/lib/kitchen/terraform/{config_predicates.rb → config_attribute_contract.rb} +3 -3
  52. data/lib/kitchen/terraform/config_attribute_contract/array_of_strings.rb +30 -0
  53. data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/boolean.rb +7 -11
  54. data/lib/kitchen/terraform/config_attribute_contract/hash_of_symbols_and_strings.rb +41 -0
  55. data/lib/kitchen/terraform/{config_schemas.rb → config_attribute_contract/integer.rb} +10 -3
  56. data/lib/kitchen/terraform/config_attribute_contract/optional_string.rb +30 -0
  57. data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/string.rb +7 -9
  58. data/lib/kitchen/terraform/config_attribute_contract/systems.rb +63 -0
  59. data/lib/kitchen/terraform/config_attribute_definer.rb +2 -2
  60. data/lib/kitchen/terraform/config_attribute_type.rb +1 -1
  61. data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +9 -16
  62. data/lib/kitchen/terraform/config_attribute_type/integer.rb +27 -23
  63. data/lib/kitchen/terraform/configurable.rb +1 -1
  64. data/lib/kitchen/terraform/debug_logger.rb +1 -1
  65. data/lib/kitchen/terraform/deprecating.rb +1 -1
  66. data/lib/kitchen/terraform/driver.rb +1 -1
  67. data/lib/kitchen/terraform/driver/create.rb +5 -5
  68. data/lib/kitchen/terraform/driver/destroy.rb +8 -8
  69. data/lib/kitchen/terraform/error.rb +1 -1
  70. data/lib/kitchen/terraform/file_path_config_attribute_definer.rb +1 -1
  71. data/lib/kitchen/terraform/inspec.rb +1 -1
  72. data/lib/kitchen/terraform/inspec/fail_fast_with_hosts.rb +1 -1
  73. data/lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb +1 -1
  74. data/lib/kitchen/terraform/inspec/without_hosts.rb +1 -1
  75. data/lib/kitchen/terraform/inspec_factory.rb +1 -1
  76. data/lib/kitchen/terraform/inspec_options_factory.rb +1 -1
  77. data/lib/kitchen/terraform/inspec_runner.rb +1 -1
  78. data/lib/kitchen/terraform/outputs_manager.rb +1 -1
  79. data/lib/kitchen/terraform/outputs_parser.rb +1 -1
  80. data/lib/kitchen/terraform/outputs_reader.rb +2 -2
  81. data/lib/kitchen/terraform/provisioner.rb +1 -1
  82. data/lib/kitchen/terraform/provisioner/converge.rb +6 -6
  83. data/lib/kitchen/terraform/raise.rb +1 -1
  84. data/lib/kitchen/terraform/raise/action_failed.rb +1 -1
  85. data/lib/kitchen/terraform/raise/client_error.rb +1 -1
  86. data/lib/kitchen/terraform/shell_out.rb +2 -2
  87. data/lib/kitchen/terraform/system.rb +1 -1
  88. data/lib/kitchen/terraform/system_attrs_inputs_resolver.rb +1 -1
  89. data/lib/kitchen/terraform/system_attrs_outputs_resolver.rb +1 -1
  90. data/lib/kitchen/terraform/system_bastion_host_resolver.rb +1 -1
  91. data/lib/kitchen/terraform/system_hosts_resolver.rb +1 -1
  92. data/lib/kitchen/terraform/system_inspec_map.rb +1 -1
  93. data/lib/kitchen/terraform/systems_verifier.rb +1 -1
  94. data/lib/kitchen/terraform/systems_verifier/fail_fast.rb +1 -1
  95. data/lib/kitchen/terraform/systems_verifier/fail_slow.rb +1 -1
  96. data/lib/kitchen/terraform/systems_verifier_factory.rb +1 -1
  97. data/lib/kitchen/terraform/unsupported_client_version_error.rb +1 -1
  98. data/lib/kitchen/terraform/variables_manager.rb +1 -1
  99. data/lib/kitchen/terraform/verify_version.rb +1 -1
  100. data/lib/kitchen/terraform/verify_version_rescue_strategy.rb +1 -1
  101. data/lib/kitchen/terraform/verify_version_rescue_strategy/permissive.rb +1 -1
  102. data/lib/kitchen/terraform/verify_version_rescue_strategy/strict.rb +1 -1
  103. data/lib/kitchen/terraform/verify_version_rescue_strategy_factory.rb +1 -1
  104. data/lib/kitchen/terraform/version.rb +2 -2
  105. data/lib/kitchen/terraform/version_verifier.rb +1 -1
  106. data/lib/kitchen/terraform/version_verifier_strategy.rb +1 -1
  107. data/lib/kitchen/terraform/version_verifier_strategy/supported.rb +1 -1
  108. data/lib/kitchen/terraform/version_verifier_strategy/unsupported.rb +1 -1
  109. data/lib/kitchen/terraform/version_verifier_strategy_factory.rb +1 -1
  110. data/lib/kitchen/verifier/terraform.rb +1 -1
  111. metadata +60 -49
  112. metadata.gz.sig +0 -0
  113. data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +0 -81
  114. data/lib/kitchen/terraform/config_schemas/array_of_strings.rb +0 -38
  115. data/lib/kitchen/terraform/config_schemas/optional_string.rb +0 -38
  116. data/lib/kitchen/terraform/config_schemas/system.rb +0 -609
  117. 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-2019 New Context, Inc.
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,7 +16,7 @@
16
16
 
17
17
  require "kitchen/terraform/config_attribute"
18
18
  require "kitchen/terraform/config_attribute_cacher"
19
- require "kitchen/terraform/config_schemas/array_of_strings"
19
+ require "kitchen/terraform/config_attribute_contract/array_of_strings"
20
20
  require "kitchen/terraform/file_path_config_attribute_definer"
21
21
 
22
22
  module Kitchen
@@ -42,7 +42,7 @@ module Kitchen
42
42
  def included(plugin_class)
43
43
  ::Kitchen::Terraform::FilePathConfigAttributeDefiner.new(
44
44
  attribute: self,
45
- schema: ::Kitchen::Terraform::ConfigSchemas::ArrayOfStrings,
45
+ schema: ::Kitchen::Terraform::ConfigAttributeContract::ArrayOfStrings.new,
46
46
  ).define plugin_class: plugin_class
47
47
  end
48
48
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
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.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
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,7 +16,7 @@
16
16
 
17
17
  require "kitchen"
18
18
  require "kitchen/terraform/config_attribute"
19
- require "kitchen/terraform/config_schemas/boolean"
19
+ require "kitchen/terraform/config_attribute_contract/boolean"
20
20
 
21
21
  module Kitchen
22
22
  module Terraform
@@ -34,7 +34,7 @@ module Kitchen
34
34
  default_value: lambda do
35
35
  true
36
36
  end,
37
- schema: ::Kitchen::Terraform::ConfigSchemas::Boolean,
37
+ schema: ::Kitchen::Terraform::ConfigAttributeContract::Boolean.new,
38
38
  ).apply config_attribute: self
39
39
  end
40
40
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
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.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
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
- # The namespace for configuration attribute predicates.
20
- module ConfigPredicates
19
+ # ConfigAttributeContract is the namespace for configuration attribute contracts.
20
+ module ConfigAttributeContract
21
21
  end
22
22
  end
23
23
  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
+ # ArrayOfStrings is the class of objects that provide a configuration attribute contract for an array of strings.
23
+ class ArrayOfStrings < ::Dry::Validation::Contract
24
+ schema do
25
+ required(:value).array :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-2019 New Context, Inc.
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 ConfigSchemas
22
- # A validation schema for a configuration attribute which is a boolean.
23
- #
24
- # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
25
- Boolean = ::Dry::Validation.Schema do
26
- required(:value).filled :bool?
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-2019 New Context, Inc.
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
- # The namespace for configuration attribute schemas.
20
- module ConfigSchemas
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-2019 New Context, Inc.
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 ConfigSchemas
22
- # Defines a validation schema for a string.
23
- String = ::Dry::Validation.Schema do
24
- required(:value).filled :str?
25
- end.dup
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-2019 New Context, Inc.
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).messages, plugin_class: plugin_class
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-2019 New Context, Inc.
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.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
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/config_predicates/hash_of_symbols_and_strings"
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 which
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
- .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
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-2019 New Context, Inc.
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
- # This module applies the behaviour of a configuration attribute of type integer to a module which must be included by a
22
- # plugin class.
23
- #
24
- # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
25
- module ::Kitchen::Terraform::ConfigAttributeType::Integer
26
- # This method applies the configuration attribute behaviour to a module.
27
- #
28
- # @param attribute [Symbol] the symbol corresponding to the configuration attribute.
29
- # @param config_attribute [Module] a module.
30
- # @param default_value [Proc] a proc which returns the default value.
31
- # @return [self]
32
- def self.apply(attribute:, config_attribute:, default_value:)
33
- ::Kitchen::Terraform::ConfigAttribute
34
- .new(
35
- attribute: attribute,
36
- default_value: default_value,
37
- schema: ::Dry::Validation
38
- .Schema do
39
- required(:value).filled :int?
40
- end,
41
- ).apply config_attribute: config_attribute
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
- self
44
+ self
45
+ end
46
+ end
47
+ end
44
48
  end
45
49
  end