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.
Files changed (111) 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 +37 -173
  5. data/lib/kitchen/driver/terraform.rb +196 -514
  6. data/lib/kitchen/provisioner/terraform.rb +88 -86
  7. data/lib/kitchen/terraform.rb +5 -6
  8. data/lib/kitchen/terraform/breaking.rb +7 -5
  9. data/lib/kitchen/terraform/command.rb +7 -5
  10. data/lib/kitchen/terraform/command/apply.rb +87 -0
  11. data/lib/kitchen/terraform/command/destroy.rb +88 -0
  12. data/lib/kitchen/terraform/command/get.rb +32 -0
  13. data/lib/kitchen/terraform/command/init.rb +102 -0
  14. data/lib/kitchen/terraform/command/output.rb +11 -50
  15. data/lib/kitchen/terraform/command/validate.rb +63 -0
  16. data/lib/kitchen/terraform/command/version.rb +5 -42
  17. data/lib/kitchen/terraform/command/workspace_delete.rb +41 -0
  18. data/lib/kitchen/terraform/command/workspace_new.rb +43 -0
  19. data/lib/kitchen/terraform/command/workspace_select.rb +43 -0
  20. data/lib/kitchen/terraform/command_executor.rb +60 -0
  21. data/lib/kitchen/terraform/command_flag.rb +23 -0
  22. data/lib/kitchen/terraform/command_flag/backend_config.rb +43 -0
  23. data/lib/kitchen/terraform/command_flag/color.rb +45 -0
  24. data/lib/kitchen/terraform/command_flag/lock_timeout.rb +42 -0
  25. data/lib/kitchen/terraform/command_flag/plugin_dir.rb +47 -0
  26. data/lib/kitchen/terraform/command_flag/upgrade.rb +45 -0
  27. data/lib/kitchen/terraform/command_flag/var.rb +43 -0
  28. data/lib/kitchen/terraform/command_flag/var_file.rb +45 -0
  29. data/lib/kitchen/terraform/config_attribute.rb +58 -55
  30. data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +1 -1
  31. data/lib/kitchen/terraform/config_attribute/client.rb +10 -3
  32. data/lib/kitchen/terraform/config_attribute/color.rb +1 -1
  33. data/lib/kitchen/terraform/config_attribute/command_timeout.rb +1 -1
  34. data/lib/kitchen/terraform/config_attribute/fail_fast.rb +1 -1
  35. data/lib/kitchen/terraform/config_attribute/lock.rb +1 -1
  36. data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +1 -1
  37. data/lib/kitchen/terraform/config_attribute/parallelism.rb +1 -1
  38. data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +3 -3
  39. data/lib/kitchen/terraform/config_attribute/root_module_directory.rb +4 -4
  40. data/lib/kitchen/terraform/config_attribute/systems.rb +1 -1
  41. data/lib/kitchen/terraform/config_attribute/variable_files.rb +4 -4
  42. data/lib/kitchen/terraform/config_attribute/variables.rb +1 -1
  43. data/lib/kitchen/terraform/config_attribute/verify_version.rb +2 -2
  44. data/lib/kitchen/terraform/config_attribute_cacher.rb +27 -25
  45. data/lib/kitchen/terraform/config_attribute_definer.rb +37 -43
  46. data/lib/kitchen/terraform/config_attribute_type.rb +7 -5
  47. data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +32 -27
  48. data/lib/kitchen/terraform/config_attribute_type/integer.rb +4 -4
  49. data/lib/kitchen/terraform/config_predicates.rb +7 -5
  50. data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +6 -6
  51. data/lib/kitchen/terraform/config_schemas.rb +7 -5
  52. data/lib/kitchen/terraform/config_schemas/array_of_strings.rb +20 -13
  53. data/lib/kitchen/terraform/config_schemas/boolean.rb +16 -9
  54. data/lib/kitchen/terraform/config_schemas/optional_string.rb +20 -13
  55. data/lib/kitchen/terraform/config_schemas/string.rb +13 -7
  56. data/lib/kitchen/terraform/config_schemas/system.rb +38 -16
  57. data/lib/kitchen/terraform/config_schemas/systems.rb +5 -2
  58. data/lib/kitchen/terraform/configurable.rb +41 -21
  59. data/lib/kitchen/terraform/debug_logger.rb +1 -1
  60. data/lib/kitchen/terraform/deprecating.rb +7 -5
  61. data/lib/kitchen/terraform/driver.rb +23 -0
  62. data/lib/kitchen/terraform/driver/create.rb +120 -0
  63. data/lib/kitchen/terraform/driver/destroy.rb +169 -0
  64. data/lib/kitchen/terraform/error.rb +7 -5
  65. data/lib/kitchen/terraform/file_path_config_attribute_definer.rb +30 -27
  66. data/lib/kitchen/terraform/inspec.rb +3 -57
  67. data/lib/kitchen/terraform/inspec/fail_fast_with_hosts.rb +59 -0
  68. data/lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb +69 -0
  69. data/lib/kitchen/terraform/inspec/without_hosts.rb +52 -0
  70. data/lib/kitchen/terraform/inspec_factory.rb +68 -0
  71. data/lib/kitchen/terraform/inspec_options_factory.rb +86 -0
  72. data/lib/kitchen/terraform/inspec_runner.rb +88 -0
  73. data/lib/kitchen/terraform/outputs_manager.rb +64 -0
  74. data/lib/kitchen/terraform/outputs_parser.rb +39 -0
  75. data/lib/kitchen/terraform/outputs_reader.rb +63 -0
  76. data/lib/kitchen/terraform/provisioner.rb +23 -0
  77. data/lib/kitchen/terraform/provisioner/converge.rb +206 -0
  78. data/lib/kitchen/terraform/raise.rb +23 -0
  79. data/lib/kitchen/terraform/raise/action_failed.rb +49 -0
  80. data/lib/kitchen/terraform/raise/client_error.rb +49 -0
  81. data/lib/kitchen/terraform/shell_out.rb +90 -59
  82. data/lib/kitchen/terraform/system.rb +63 -93
  83. data/lib/kitchen/terraform/system_attrs_inputs_resolver.rb +49 -0
  84. data/lib/kitchen/terraform/system_attrs_outputs_resolver.rb +80 -0
  85. data/lib/kitchen/terraform/system_bastion_host_resolver.rb +72 -0
  86. data/lib/kitchen/terraform/system_hosts_resolver.rb +39 -17
  87. data/lib/kitchen/terraform/system_inspec_map.rb +49 -0
  88. data/lib/kitchen/terraform/systems_verifier.rb +23 -0
  89. data/lib/kitchen/terraform/systems_verifier/fail_fast.rb +52 -0
  90. data/lib/kitchen/terraform/systems_verifier/fail_slow.rb +62 -0
  91. data/lib/kitchen/terraform/systems_verifier_factory.rb +50 -0
  92. data/lib/kitchen/terraform/unsupported_client_version_error.rb +26 -0
  93. data/lib/kitchen/terraform/variables_manager.rb +64 -0
  94. data/lib/kitchen/terraform/verify_version.rb +63 -20
  95. data/lib/kitchen/terraform/verify_version_rescue_strategy.rb +23 -0
  96. data/lib/kitchen/terraform/verify_version_rescue_strategy/permissive.rb +50 -0
  97. data/lib/kitchen/terraform/verify_version_rescue_strategy/strict.rb +47 -0
  98. data/lib/kitchen/terraform/verify_version_rescue_strategy_factory.rb +51 -0
  99. data/lib/kitchen/terraform/version.rb +59 -58
  100. data/lib/kitchen/terraform/version_verifier.rb +50 -0
  101. data/lib/kitchen/terraform/version_verifier_strategy.rb +25 -0
  102. data/lib/kitchen/terraform/version_verifier_strategy/supported.rb +33 -0
  103. data/lib/kitchen/terraform/version_verifier_strategy/unsupported.rb +34 -0
  104. data/lib/kitchen/terraform/version_verifier_strategy_factory.rb +50 -0
  105. data/lib/kitchen/verifier/terraform.rb +71 -62
  106. metadata +143 -80
  107. metadata.gz.sig +0 -0
  108. data/lib/kitchen/terraform/inspec_options_mapper.rb +0 -73
  109. data/lib/kitchen/terraform/inspec_with_hosts.rb +0 -50
  110. data/lib/kitchen/terraform/inspec_without_hosts.rb +0 -45
  111. 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 Services, Inc.
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.
@@ -25,9 +25,9 @@ require "kitchen/terraform/config_attribute_type"
25
25
  module ::Kitchen::Terraform::ConfigAttributeType::Integer
26
26
  # This method applies the configuration attribute behaviour to a module.
27
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.
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
31
  # @return [self]
32
32
  def self.apply(attribute:, config_attribute:, default_value:)
33
33
  ::Kitchen::Terraform::ConfigAttribute
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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
- require "kitchen/terraform"
18
-
19
- # The namespace for configuration attribute predicates.
20
- module ::Kitchen::Terraform::ConfigPredicates
17
+ module Kitchen
18
+ module Terraform
19
+ # The namespace for configuration attribute predicates.
20
+ module ConfigPredicates
21
+ end
22
+ end
21
23
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -25,7 +25,7 @@ require "kitchen/terraform/config_predicates"
25
25
  module ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
26
26
  # A callback to configure an extending schema with this predicate.
27
27
  #
28
- # @param schema [::Dry::Validation::Schema] the schema to be configured.
28
+ # @param schema [Dry::Validation::Schema] the schema to be configured.
29
29
  # @return [self]
30
30
  def self.extended(schema)
31
31
  schema.predicates self
@@ -45,8 +45,8 @@ module ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
45
45
  # If all keys are symbols then the result is +true+; else the result is +false+.
46
46
  #
47
47
  # @api private
48
- # @param keys [::Enumerable] keys that must be only symbols
49
- # @return [::TrueClass, ::FalseClass] the result
48
+ # @param keys [Enumerable] keys that must be only symbols
49
+ # @return [TrueClass, ::FalseClass] the result
50
50
  def self.all_symbols?(keys:)
51
51
  keys
52
52
  .all? do |key|
@@ -57,8 +57,8 @@ module ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
57
57
  # If all values are strings then the result is +true+; else the result is +false+.
58
58
  #
59
59
  # @api private
60
- # @param values [::Enumerable] values that must be only strings
61
- # @return [::TrueClass, ::FalseClass] the result
60
+ # @param values [Enumerable] values that must be only strings
61
+ # @return [TrueClass, ::FalseClass] the result
62
62
  def self.all_strings?(values:)
63
63
  values
64
64
  .all? do |value|
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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
- require "kitchen/terraform"
18
-
19
- # The namespace for configuration attribute schemas.
20
- module ::Kitchen::Terraform::ConfigSchemas
17
+ module Kitchen
18
+ module Terraform
19
+ # The namespace for configuration attribute schemas.
20
+ module ConfigSchemas
21
+ end
22
+ end
21
23
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -15,17 +15,24 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "dry/validation"
18
- require "kitchen/terraform/config_schemas"
19
18
 
20
- # A validation schema for a configuration attribute which is an array including only strings.
21
- #
22
- # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
23
- ::Kitchen::Terraform::ConfigSchemas::ArrayOfStrings =
24
- ::Dry::Validation
25
- .Schema do
26
- required(:value)
27
- .each(
28
- :filled?,
29
- :str?
30
- )
19
+ module Kitchen
20
+ module Terraform
21
+ module ConfigSchemas
22
+ # A validation schema for a configuration attribute which is an array including only strings.
23
+ #
24
+ # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
25
+ ArrayOfStrings = ::Dry::Validation.Schema do
26
+ required(:value)
27
+ .each(
28
+ :filled?,
29
+ :str?
30
+ )
31
+ end.dup
32
+
33
+ ArrayOfStrings.define_singleton_method :to_s do
34
+ "Kitchen::Terraform::ConfigSchemas::ArrayOfStrings"
35
+ end
36
+ end
31
37
  end
38
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -15,13 +15,20 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "dry/validation"
18
- require "kitchen/terraform/config_schemas"
19
18
 
20
- # A validation schema for a configuration attribute which is a boolean.
21
- #
22
- # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
23
- ::Kitchen::Terraform::ConfigSchemas::Boolean =
24
- ::Dry::Validation
25
- .Schema do
26
- required(:value).filled :bool?
19
+ module Kitchen
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"
31
+ end
32
+ end
27
33
  end
34
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -15,17 +15,24 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "dry/validation"
18
- require "kitchen/terraform/config_schemas"
19
18
 
20
- # A validation schema for a configuration attribute which is an optional string.
21
- #
22
- # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
23
- ::Kitchen::Terraform::ConfigSchemas::OptionalString =
24
- ::Dry::Validation
25
- .Schema do
26
- required(:value)
27
- .maybe(
28
- :str?,
29
- :filled?
30
- )
19
+ module Kitchen
20
+ module Terraform
21
+ module ConfigSchemas
22
+ # A validation schema for a configuration attribute which is an optional string.
23
+ #
24
+ # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
25
+ OptionalString = ::Dry::Validation.Schema do
26
+ required(:value)
27
+ .maybe(
28
+ :str?,
29
+ :filled?
30
+ )
31
+ end.dup
32
+
33
+ OptionalString.define_singleton_method :to_s do
34
+ "Kitchen::Terraform::ConfigSchemas::OptionalString"
35
+ end
36
+ end
31
37
  end
38
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -15,12 +15,18 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "dry/validation"
18
- require "kitchen/terraform/config_schemas"
19
18
 
20
- # Defines a validation schema for a string.
19
+ module Kitchen
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
21
26
 
22
- ::Kitchen::Terraform::ConfigSchemas::String =
23
- ::Dry::Validation
24
- .Schema do
25
- required(:value).filled :str?
27
+ String.define_singleton_method :to_s do
28
+ "Kitchen::Terraform::ConfigSchemas::String"
29
+ end
30
+ end
26
31
  end
32
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -15,7 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "dry/validation"
18
- require "kitchen/terraform/config_schemas"
19
18
 
20
19
  module Kitchen
21
20
  module Terraform
@@ -32,17 +31,16 @@ module Kitchen
32
31
  # implemented in the directory located at `<Kitchen root>/test/integration/<suite name>`. This behaviour can be
33
32
  # overridden with the <code>profile_locations</code> key.
34
33
  #
35
- # The values of any {https://www.terraform.io/docs/configuration/variables.html Terraform input variables}
36
- # configured with the driver's <code>variables</code> attribute and the values of any
37
- # {https://www.terraform.io/docs/configuration/outputs.html Terraform output variables} which exist in the
38
- # Terraform state are associated with equivalently named
34
+ # The values of any {https://www.terraform.io/docs/configuration/variables.html Terraform variables} configured
35
+ # with the driver's <code>variables</code> attribute and the values of any
36
+ # {https://www.terraform.io/docs/configuration/outputs.html Terraform outputs} which exist in the Terraform state
37
+ # are associated with equivalently named
39
38
  # {https://www.inspec.io/docs/reference/profiles/#profile-attributes InSpec profile attributes}, prefixed with
40
- # <code>input_</code> or <code>output_</code>, respectively. The values of the output variables are also
41
- # associated with equivalently named profile attributes without any prefixes for backward compatibility. Output
42
- # variable associations can be overridden with the <code>attrs_outputs</code> key. For example, the value of an
43
- # input variable named `test` will be associated with an attribute named `input_test`, and the value of an output
44
- # variable named `test` will be associated with an attribute named `output_test` as well as an attribute named
45
- # `test`.
39
+ # <code>input_</code> or <code>output_</code>, respectively. The values of the outputs are also associated with
40
+ # equivalently named profile attributes without any prefixes for backward compatibility. Output associations can
41
+ # be overridden with the <code>attrs_outputs</code> key. For example, the value of a variable named `test` will
42
+ # be associated with an attribute named `input_test`, and the value of an output named `test` will be associated
43
+ # with an attribute named `output_test` as well as an attribute named `test`.
46
44
  #
47
45
  # ===== Required Keys
48
46
  #
@@ -132,6 +130,8 @@ module Kitchen
132
130
  #
133
131
  # The +bastion_host+ key must be used in combination with a backend which supports remote connections.
134
132
  #
133
+ # The +bastion_host_output+ key will take priority over the +bastion_host+ key.
134
+ #
135
135
  # <em>Example kitchen.yml</em>
136
136
  # verifier:
137
137
  # name: terraform
@@ -140,12 +140,29 @@ module Kitchen
140
140
  # backend: ssh
141
141
  # bastion_host: bastion-host.domain
142
142
  #
143
+ # ====== bastion_host_output
144
+ #
145
+ # The value of the +bastion_host_output+ key is a scalar which is used to obtain the address of a bastion host in
146
+ # the system from a Terraform output.
147
+ #
148
+ # The scalar must match the name of an output with a value which is a string.
149
+ #
150
+ # The +bastion_host_output+ key must be used in combination with a backend which enables remote connections.
151
+ #
152
+ # <em>Example kitchen.yml</em>
153
+ # verifier:
154
+ # name: terraform
155
+ # systems:
156
+ # - name: a system
157
+ # backend: ssh
158
+ # bastion_host_output: an_output
159
+ #
143
160
  # ====== bastion_port
144
161
  #
145
162
  # The value of the +bastion_port+ key is an integer which is used as the port number to connect to on the bastion
146
163
  # host.
147
164
  #
148
- # The +bastion_port+ key must be used in combination with the +bastion_host+ key.
165
+ # The +bastion_port+ key must be used in combination with the +bastion_host_output+ key or the +bastion_host+ key.
149
166
  #
150
167
  # <em>Example kitchen.yml</em>
151
168
  # verifier:
@@ -153,7 +170,7 @@ module Kitchen
153
170
  # systems:
154
171
  # - name: a system
155
172
  # backend: ssh
156
- # bastion_host: bastion-host.domain
173
+ # bastion_host_output: an_output
157
174
  # bastion_port: 1234
158
175
  #
159
176
  # ====== bastion_user
@@ -161,7 +178,7 @@ module Kitchen
161
178
  # The value of the +bastion_user+ key is a scalar which is used as the username for authentication with the
162
179
  # bastion host.
163
180
  #
164
- # The +bastion_user+ key must be used in combination with the +bastion_host+ key.
181
+ # The +bastion_user+ key must be used in combination with the +bastion_host_output+ key or the +bastion_host+ key.
165
182
  #
166
183
  # <em>Example kitchen.yml</em>
167
184
  # verifier:
@@ -169,7 +186,7 @@ module Kitchen
169
186
  # systems:
170
187
  # - name: a system
171
188
  # backend: ssh
172
- # bastion_host: bastion-host.domain
189
+ # bastion_host_output: an_output
173
190
  # bastion_user: bastion-user
174
191
  #
175
192
  # ====== controls
@@ -556,6 +573,7 @@ module Kitchen
556
573
  optional(:attrs_outputs).filled :hash?
557
574
  optional(:backend_cache).value :bool?
558
575
  optional(:bastion_host).filled :str?
576
+ optional(:bastion_host_output).filled :str?
559
577
  optional(:bastion_port).value :int?
560
578
  optional(:bastion_user).filled :str?
561
579
  optional(:controls).each(:filled?, :str?)
@@ -581,6 +599,10 @@ module Kitchen
581
599
  optional(:sudo_password).filled :str?
582
600
  optional(:user).filled :str?
583
601
  optional(:vendor_cache).filled :str?
602
+ end.dup
603
+
604
+ System.define_singleton_method :to_s do
605
+ "Kitchen::Terraform::ConfigSchemas::System"
584
606
  end
585
607
  end
586
608
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -15,7 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "dry/validation"
18
- require "kitchen/terraform/config_schemas"
19
18
  require "kitchen/terraform/config_schemas/system"
20
19
 
21
20
  module Kitchen
@@ -28,6 +27,10 @@ module Kitchen
28
27
  required(:value).each do
29
28
  schema ::Kitchen::Terraform::ConfigSchemas::System
30
29
  end
30
+ end.dup
31
+
32
+ Systems.define_singleton_method :to_s do
33
+ "Kitchen::Terraform::ConfigSchemas::Systems"
31
34
  end
32
35
  end
33
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016 New Context Services, Inc.
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.
@@ -15,30 +15,50 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "kitchen"
18
- require "kitchen/terraform"
19
18
  require "kitchen/terraform/version"
19
+ require "rubygems"
20
+ require "shellwords"
20
21
 
21
- # Refinements to Kitchen::Configurable.
22
- #
23
- # @see https://github.com/test-kitchen/test-kitchen/blob/v1.16.0/lib/kitchen/configurable.rb Kitchen::Configurable
24
- module ::Kitchen::Terraform::Configurable
25
- # A callback to define the plugin version which is invoked when this module is included in a plugin class.
26
- #
27
- # @return [self]
28
- def self.included(configurable_class)
29
- ::Kitchen::Terraform::Version.assign_plugin_version configurable_class: configurable_class
30
- self
31
- end
22
+ module Kitchen
23
+ module Terraform
24
+ # Refinements to Kitchen::Configurable.
25
+ # This class implements the interface of Kitchen::Configurable which requires the following Reek suppressions:
26
+ # :reek:MissingSafeMethod { exclude: [ finalize_config! ] }
27
+ # @see https://github.com/test-kitchen/test-kitchen/blob/v1.16.0/lib/kitchen/configurable.rb Kitchen::Configurable
28
+ module Configurable
29
+ # A callback to define the plugin version which is invoked when this module is included in a plugin class.
30
+ #
31
+ # @return [self]
32
+ def self.included(configurable_class)
33
+ ::Kitchen::Terraform::Version.assign_plugin_version configurable_class: configurable_class
34
+ self
35
+ end
32
36
 
33
- private
37
+ # #finalize_config! invokes the super implementation and then defines the workspace name and version requirement.
38
+ #
39
+ # @param instance [Kitchen::Instance] an associated instance.
40
+ # @raise [Kitchen::ClientError] if the instance is nil.
41
+ # @return [self]
42
+ # @see Kitchen::Configurable#finalize_config!
43
+ def finalize_config!(instance)
44
+ super instance
45
+ self.version_requirement = ::Gem::Requirement.new ">= 0.11.4", "< 0.15.0"
46
+ self.workspace_name = "kitchen-terraform-#{::Shellwords.escape instance.name}"
47
+ end
34
48
 
35
- def expand_paths!
36
- validate_config! if !@validate_config_called
37
- super
38
- end
49
+ private
50
+
51
+ attr_accessor :version_requirement, :workspace_name
52
+
53
+ def expand_paths!
54
+ validate_config! if !@validate_config_called
55
+ super
56
+ end
39
57
 
40
- def validate_config!
41
- @validate_config_called ||= true
42
- super
58
+ def validate_config!
59
+ @validate_config_called ||= true
60
+ super
61
+ end
62
+ end
43
63
  end
44
64
  end