kitchen-terraform 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/kitchen/driver/terraform.rb +127 -35
  5. data/lib/kitchen/provisioner/terraform.rb +7 -1
  6. data/lib/kitchen/{verifier.rb → terraform/breaking.rb} +3 -4
  7. data/lib/kitchen/{driver.rb → terraform/breaking/kitchen_instance.rb} +4 -3
  8. data/lib/kitchen/terraform/config_attribute.rb +68 -4
  9. data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +10 -38
  10. data/lib/kitchen/terraform/config_attribute/color.rb +10 -35
  11. data/lib/kitchen/terraform/config_attribute/command_timeout.rb +10 -29
  12. data/lib/kitchen/terraform/config_attribute/groups.rb +10 -28
  13. data/lib/kitchen/terraform/config_attribute/lock.rb +10 -33
  14. data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +10 -34
  15. data/lib/kitchen/terraform/config_attribute/parallelism.rb +10 -34
  16. data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +0 -5
  17. data/lib/kitchen/terraform/config_attribute/variable_files.rb +0 -9
  18. data/lib/kitchen/terraform/config_attribute/variables.rb +10 -38
  19. data/lib/kitchen/{provisioner.rb → terraform/config_attribute_type.rb} +3 -4
  20. data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +51 -0
  21. data/lib/kitchen/terraform/config_attribute_type/integer.rb +47 -0
  22. data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +9 -0
  23. data/lib/kitchen/terraform/configurable.rb +11 -7
  24. data/lib/kitchen/terraform/{config_schemas/integer.rb → deprecating.rb} +4 -10
  25. data/lib/kitchen/terraform/deprecating/kitchen_instance.rb +61 -0
  26. data/lib/kitchen/terraform/kitchen_instance.rb +49 -0
  27. data/lib/kitchen/terraform/version.rb +23 -1
  28. data/lib/kitchen/verifier/terraform.rb +7 -1
  29. metadata +26 -22
  30. metadata.gz.sig +0 -0
  31. data/lib/kitchen/terraform/config_schemas/hash_of_symbols_and_strings.rb +0 -32
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2016 New Context Services, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "dry-validation"
18
+ require "kitchen/terraform/config_attribute"
19
+ require "kitchen/terraform/config_attribute_type"
20
+
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:
38
+ ::Dry::Validation
39
+ .Schema do
40
+ required(:value).filled :int?
41
+ end
42
+ )
43
+ .apply config_attribute: config_attribute
44
+
45
+ self
46
+ end
47
+ end
@@ -23,6 +23,15 @@ require "kitchen/terraform/config_predicates"
23
23
  #
24
24
  # @see http://dry-rb.org/gems/dry-validation/custom-predicates/ DRY Logic Custom Predicates
25
25
  module ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
26
+ # A callback to configure an extending schema with this predicate.
27
+ #
28
+ # @param schema [::Dry::Validation::Schema] the schema to be configured.
29
+ # @return [self]
30
+ def self.extended(schema)
31
+ schema.predicates self
32
+ self
33
+ end
34
+
26
35
  include ::Dry::Logic::Predicates
27
36
 
28
37
  predicate :hash_of_symbols_and_strings? do |value|
@@ -16,6 +16,7 @@
16
16
 
17
17
  require "kitchen"
18
18
  require "kitchen/terraform"
19
+ require "kitchen/terraform/kitchen_instance"
19
20
  require "kitchen/terraform/version"
20
21
 
21
22
  # Refinements to Kitchen::Configurable.
@@ -24,33 +25,36 @@ require "kitchen/terraform/version"
24
25
  module ::Kitchen::Terraform::Configurable
25
26
  # A callback to define the plugin version which is invoked when this module is included in a plugin class.
26
27
  #
27
- # @return [void]
28
+ # @return [self]
28
29
  def self.included(configurable_class)
29
- configurable_class.plugin_version ::Kitchen::Terraform::VERSION
30
+ ::Kitchen::Terraform::Version
31
+ .new
32
+ .assign_plugin_version configurable_class: configurable_class
33
+
34
+ self
30
35
  end
31
36
 
32
37
  # Alternative implementation of Kitchen::Configurable#finalize_config! which validates the configuration before
33
38
  # attempting to expand paths.
34
39
  #
35
40
  # @note this method should be removed when Test Kitchen: Issue #1229 is solved.
36
- # @param instance [::Kitchen::Instance] an associated instance.
41
+ # @param kitchen_instance [::Kitchen::Instance] an associated Test Kitchen instance.
37
42
  # @return [self] itself, for use in chaining.
38
43
  # @raise [::Kitchen::ClientError] if the instance is nil.
39
44
  # @see https://github.com/test-kitchen/test-kitchen/blob/v1.16.0/lib/kitchen/configurable.rb#L46
40
45
  # Kitchen::Configurable#finalize_config!
41
46
  # @see https://github.com/test-kitchen/test-kitchen/issues/1229 Test Kitchen: Issue #1229
42
- def finalize_config!(instance)
43
- instance or
47
+ def finalize_config!(kitchen_instance)
48
+ kitchen_instance or
44
49
  raise(
45
50
  ::Kitchen::ClientError,
46
51
  "Instance must be provided to #{self}"
47
52
  )
48
53
 
49
- @instance = instance
54
+ @instance = ::Kitchen::Terraform::KitchenInstance.new kitchen_instance: kitchen_instance
50
55
  validate_config!
51
56
  expand_paths!
52
57
  load_needed_dependencies!
53
-
54
58
  self
55
59
  end
56
60
  end
@@ -14,14 +14,8 @@
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
- require "kitchen/terraform/config_schemas"
17
+ require "kitchen/terraform"
19
18
 
20
- # A validation schema for a configuration attribute which is an integer.
21
- #
22
- # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
23
- ::Kitchen::Terraform::ConfigSchemas::Integer =
24
- ::Dry::Validation
25
- .Schema do
26
- required(:value).filled :int?
27
- end
19
+ # The namespace for objects with deprecating changes.
20
+ module ::Kitchen::Terraform::Deprecating
21
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2016 New Context Services, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "delegate"
18
+ require "kitchen"
19
+ require "kitchen/terraform/deprecating"
20
+
21
+ # This class provides the deprecating change to the KitchenInstance.
22
+ class ::Kitchen::Terraform::Deprecating::KitchenInstance < DelegateClass ::Kitchen::Instance
23
+ private
24
+
25
+ # Runs a given action block directly.
26
+ #
27
+ # If the desired action is one of +:create+, +:converge+, +:setup+, or +:destroy+, and there is more than one thread
28
+ # active, then a warning is issued about deprecating support for concurrency with the desired action.
29
+ #
30
+ # @api private
31
+ # @param action [::Symbol] the action to be performed
32
+ # @param state [::Hash] a mutable state hash for this instance
33
+ # @see ::Kitchen::Instance
34
+ # @yieldparam state [::Hash] a mutable state hash for this instance
35
+ def synchronize_or_call(action, state)
36
+ ::Thread
37
+ .list
38
+ .length
39
+ .>(1) and
40
+ issue_warning action: action
41
+
42
+ yield state
43
+ end
44
+
45
+ # @api private
46
+ def issue_warning(action:)
47
+ [
48
+ :create,
49
+ :converge,
50
+ :setup,
51
+ :destroy
52
+ ]
53
+ .grep action do |serial_action|
54
+ warn(
55
+ "DEPRECATING: #{to_str} is about to invoke #{driver.class}##{serial_action} with concurrency " \
56
+ "activated; this action will be forced to run serially in an upcoming major version of " \
57
+ "Kitchen-Terraform"
58
+ )
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2016 New Context Services, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "kitchen/terraform"
18
+ require "kitchen/terraform/breaking/kitchen_instance"
19
+ require "kitchen/terraform/deprecating/kitchen_instance"
20
+ require "kitchen/terraform/version"
21
+ require "rubygems"
22
+
23
+ # This module is a factory for KitchenInstances.
24
+ #
25
+ # KitchenInstances wrap ::Kitchen::Instance in order to provide a contextual deprecation warning for actions which will
26
+ # no longer support concurrency.
27
+ module ::Kitchen::Terraform::KitchenInstance
28
+ # Creates a new KitchenInstance.
29
+ #
30
+ # If the version satisfies the requirement of +~> 3.3+ then a breaking KitchenInstance is created.
31
+ #
32
+ # If the version satisfies the requirement of +>= 4+ then a breaking KitchenInstance is created.
33
+ #
34
+ # @param kitchen_instance [::Kitchen::Instance] the ::Kitchen::Instance which will act as the delegate.
35
+ # @param version [::Kitchen::Terraform::Version] the version to compare against the requirement.
36
+ # @return [::Kitchen::Terraform::Breaking::KitchenInstance, ::Kitchen::Terraform::Deprecating::KitchenInstance] the
37
+ # new KitchenInstance.
38
+ def self.new(kitchen_instance:, version: ::Kitchen::Terraform::Version.new)
39
+ version
40
+ .if_satisfies requirement: ::Gem::Requirement.new("~> 3.3") do
41
+ return ::Kitchen::Terraform::Deprecating::KitchenInstance.new kitchen_instance
42
+ end
43
+
44
+ version
45
+ .if_satisfies requirement: ::Gem::Requirement.new(">= 4") do
46
+ return ::Kitchen::Terraform::Breaking::KitchenInstance.new kitchen_instance
47
+ end
48
+ end
49
+ end
@@ -14,7 +14,29 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
+ require "rubygems"
17
18
  require "kitchen/terraform"
18
19
 
19
20
  # The version of the kitchen-terraform gem.
20
- ::Kitchen::Terraform::VERSION = "3.3.0".freeze
21
+ class ::Kitchen::Terraform::Version
22
+ def assign_specification_version(specification:)
23
+ specification.version = @version.to_s
24
+ self
25
+ end
26
+
27
+ def assign_plugin_version(configurable_class:)
28
+ configurable_class.plugin_version @version.to_s
29
+ self
30
+ end
31
+
32
+ def if_satisfies(requirement:)
33
+ yield if requirement.satisfied_by? @version
34
+ self
35
+ end
36
+
37
+ private
38
+
39
+ def initialize(version: "3.3.1")
40
+ @version = ::Gem::Version.new version
41
+ end
42
+ end
@@ -14,13 +14,19 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require "kitchen/verifier"
17
+ require "kitchen"
18
18
  require "kitchen/terraform/config_attribute/color"
19
19
  require "kitchen/terraform/config_attribute/groups"
20
20
  require "kitchen/terraform/configurable"
21
21
  require "kitchen/terraform/error"
22
22
  require "kitchen/verifier/inspec"
23
23
 
24
+ # This namespace is defined by Kitchen.
25
+ #
26
+ # @see http://www.rubydoc.info/gems/test-kitchen/Kitchen/Verifier
27
+ module ::Kitchen::Verifier
28
+ end
29
+
24
30
  # The verifier utilizes the {https://www.inspec.io/ InSpec infrastructure testing framework} to verify the behaviour and
25
31
  # state of resources in the Terraform state.
26
32
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lane
@@ -55,7 +55,7 @@ cert_chain:
55
55
  XjOfZudLs1zJ8ZNOuwj6KkGJ9J3XHd9hM95MtBEWlxAfYdCuW1+v7zCTfbieBEba
56
56
  UIyyldg4TuVcuRs8uKJyempT0hqx2DniseBWw3nvtgom3A==
57
57
  -----END CERTIFICATE-----
58
- date: 2018-03-22 00:00:00.000000000 Z
58
+ date: 2018-04-29 00:00:00.000000000 Z
59
59
  dependencies:
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: bundler-audit
@@ -71,20 +71,6 @@ dependencies:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
73
  version: 0.6.0
74
- - !ruby/object:Gem::Dependency
75
- name: codeclimate-test-reporter
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - "~>"
79
- - !ruby/object:Gem::Version
80
- version: '1.0'
81
- type: :development
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '1.0'
88
74
  - !ruby/object:Gem::Dependency
89
75
  name: guard
90
76
  requirement: !ruby/object:Gem::Requirement
@@ -309,6 +295,20 @@ dependencies:
309
295
  - - "~>"
310
296
  - !ruby/object:Gem::Version
311
297
  version: '1.2'
298
+ - !ruby/object:Gem::Dependency
299
+ name: simplecov
300
+ requirement: !ruby/object:Gem::Requirement
301
+ requirements:
302
+ - - "~>"
303
+ - !ruby/object:Gem::Version
304
+ version: 0.16.1
305
+ type: :development
306
+ prerelease: false
307
+ version_requirements: !ruby/object:Gem::Requirement
308
+ requirements:
309
+ - - "~>"
310
+ - !ruby/object:Gem::Version
311
+ version: 0.16.1
312
312
  - !ruby/object:Gem::Dependency
313
313
  name: travis
314
314
  requirement: !ruby/object:Gem::Requirement
@@ -416,11 +416,11 @@ extra_rdoc_files: []
416
416
  files:
417
417
  - LICENSE
418
418
  - README.md
419
- - lib/kitchen/driver.rb
420
419
  - lib/kitchen/driver/terraform.rb
421
- - lib/kitchen/provisioner.rb
422
420
  - lib/kitchen/provisioner/terraform.rb
423
421
  - lib/kitchen/terraform.rb
422
+ - lib/kitchen/terraform/breaking.rb
423
+ - lib/kitchen/terraform/breaking/kitchen_instance.rb
424
424
  - lib/kitchen/terraform/client_version_verifier.rb
425
425
  - lib/kitchen/terraform/command.rb
426
426
  - lib/kitchen/terraform/command/output.rb
@@ -438,22 +438,25 @@ files:
438
438
  - lib/kitchen/terraform/config_attribute/variables.rb
439
439
  - lib/kitchen/terraform/config_attribute_cacher.rb
440
440
  - lib/kitchen/terraform/config_attribute_definer.rb
441
+ - lib/kitchen/terraform/config_attribute_type.rb
442
+ - lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb
443
+ - lib/kitchen/terraform/config_attribute_type/integer.rb
441
444
  - lib/kitchen/terraform/config_predicates.rb
442
445
  - lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb
443
446
  - lib/kitchen/terraform/config_schemas.rb
444
447
  - lib/kitchen/terraform/config_schemas/array_of_strings.rb
445
448
  - lib/kitchen/terraform/config_schemas/boolean.rb
446
449
  - lib/kitchen/terraform/config_schemas/groups.rb
447
- - lib/kitchen/terraform/config_schemas/hash_of_symbols_and_strings.rb
448
- - lib/kitchen/terraform/config_schemas/integer.rb
449
450
  - lib/kitchen/terraform/config_schemas/optional_string.rb
450
451
  - lib/kitchen/terraform/config_schemas/string.rb
451
452
  - lib/kitchen/terraform/configurable.rb
453
+ - lib/kitchen/terraform/deprecating.rb
454
+ - lib/kitchen/terraform/deprecating/kitchen_instance.rb
452
455
  - lib/kitchen/terraform/error.rb
453
456
  - lib/kitchen/terraform/file_path_config_attribute_definer.rb
457
+ - lib/kitchen/terraform/kitchen_instance.rb
454
458
  - lib/kitchen/terraform/shell_out.rb
455
459
  - lib/kitchen/terraform/version.rb
456
- - lib/kitchen/verifier.rb
457
460
  - lib/kitchen/verifier/terraform.rb
458
461
  - lib/kitchen/verifier/terraform/configure_inspec_runner_attributes.rb
459
462
  - lib/kitchen/verifier/terraform/configure_inspec_runner_backend.rb
@@ -467,7 +470,8 @@ homepage: https://github.com/newcontext-oss/kitchen-terraform
467
470
  licenses:
468
471
  - Apache-2.0
469
472
  metadata: {}
470
- post_install_message:
473
+ post_install_message: 'DEPRECATING: the current version of Ruby is 2.2.7; this version
474
+ will not be supported in an upcoming major release of Kitchen-Terraform'
471
475
  rdoc_options: []
472
476
  require_paths:
473
477
  - lib
metadata.gz.sig CHANGED
Binary file
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright 2016 New Context Services, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- require "dry-validation"
18
- require "kitchen/terraform/config_predicates/hash_of_symbols_and_strings"
19
- require "kitchen/terraform/config_schemas"
20
-
21
- # A validation schema for a configuration attribute which is a hash including only symbol keys and string values.
22
- #
23
- # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
24
- ::Kitchen::Terraform::ConfigSchemas::HashOfSymbolsAndStrings =
25
- ::Dry::Validation
26
- .Schema do
27
- configure do
28
- predicates ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
29
- extend ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
30
- end
31
- required(:value).value :hash_of_symbols_and_strings?
32
- end