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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +21 -19
  4. data/lib/kitchen/driver/terraform.rb +1 -1
  5. data/lib/kitchen/provisioner/terraform.rb +1 -1
  6. data/lib/kitchen/terraform/breaking.rb +1 -1
  7. data/lib/kitchen/terraform/command/apply.rb +1 -1
  8. data/lib/kitchen/terraform/command/destroy.rb +1 -1
  9. data/lib/kitchen/terraform/command/get.rb +1 -1
  10. data/lib/kitchen/terraform/command/init/post_zero_fifteen_zero.rb +89 -0
  11. data/lib/kitchen/terraform/command/init/pre_zero_fifteen_zero.rb +101 -0
  12. data/lib/kitchen/terraform/command/init.rb +3 -80
  13. data/lib/kitchen/terraform/command/init_factory.rb +52 -0
  14. data/lib/kitchen/terraform/command/output.rb +1 -1
  15. data/lib/kitchen/terraform/command/validate/post_zero_fifteen_zero.rb +51 -0
  16. data/lib/kitchen/terraform/command/validate/pre_zero_fifteen_zero.rb +65 -0
  17. data/lib/kitchen/terraform/command/validate.rb +3 -41
  18. data/lib/kitchen/terraform/command/validate_factory.rb +54 -0
  19. data/lib/kitchen/terraform/command/version.rb +1 -1
  20. data/lib/kitchen/terraform/command/workspace_delete.rb +1 -1
  21. data/lib/kitchen/terraform/command/workspace_new.rb +1 -1
  22. data/lib/kitchen/terraform/command/workspace_select.rb +1 -1
  23. data/lib/kitchen/terraform/command.rb +1 -1
  24. data/lib/kitchen/terraform/command_executor.rb +3 -5
  25. data/lib/kitchen/terraform/command_flag/backend_config.rb +1 -1
  26. data/lib/kitchen/terraform/command_flag/color.rb +1 -1
  27. data/lib/kitchen/terraform/command_flag/lock_timeout.rb +1 -1
  28. data/lib/kitchen/terraform/command_flag/plugin_dir.rb +1 -1
  29. data/lib/kitchen/terraform/command_flag/upgrade.rb +2 -2
  30. data/lib/kitchen/terraform/command_flag/var.rb +1 -1
  31. data/lib/kitchen/terraform/command_flag/var_file.rb +1 -1
  32. data/lib/kitchen/terraform/command_flag.rb +1 -1
  33. data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +1 -1
  34. data/lib/kitchen/terraform/config_attribute/client.rb +3 -3
  35. data/lib/kitchen/terraform/config_attribute/color.rb +3 -3
  36. data/lib/kitchen/terraform/config_attribute/command_timeout.rb +1 -1
  37. data/lib/kitchen/terraform/config_attribute/fail_fast.rb +3 -3
  38. data/lib/kitchen/terraform/config_attribute/lock.rb +3 -3
  39. data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +1 -1
  40. data/lib/kitchen/terraform/config_attribute/parallelism.rb +1 -1
  41. data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +3 -3
  42. data/lib/kitchen/terraform/config_attribute/root_module_directory.rb +3 -3
  43. data/lib/kitchen/terraform/config_attribute/systems.rb +552 -4
  44. data/lib/kitchen/terraform/config_attribute/variable_files.rb +3 -3
  45. data/lib/kitchen/terraform/config_attribute/variables.rb +1 -1
  46. data/lib/kitchen/terraform/config_attribute/verify_version.rb +3 -3
  47. data/lib/kitchen/terraform/config_attribute.rb +1 -1
  48. data/lib/kitchen/terraform/config_attribute_cacher.rb +1 -1
  49. data/lib/kitchen/terraform/config_attribute_contract/array_of_strings.rb +30 -0
  50. data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/boolean.rb +7 -11
  51. data/lib/kitchen/terraform/config_attribute_contract/hash_of_symbols_and_strings.rb +41 -0
  52. data/lib/kitchen/terraform/{config_schemas.rb → config_attribute_contract/integer.rb} +10 -3
  53. data/lib/kitchen/terraform/config_attribute_contract/optional_string.rb +30 -0
  54. data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/string.rb +7 -9
  55. data/lib/kitchen/terraform/config_attribute_contract/systems.rb +63 -0
  56. data/lib/kitchen/terraform/{config_predicates.rb → config_attribute_contract.rb} +3 -3
  57. data/lib/kitchen/terraform/config_attribute_definer.rb +2 -2
  58. data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +9 -16
  59. data/lib/kitchen/terraform/config_attribute_type/integer.rb +27 -23
  60. data/lib/kitchen/terraform/config_attribute_type.rb +1 -1
  61. data/lib/kitchen/terraform/configurable.rb +2 -2
  62. data/lib/kitchen/terraform/debug_logger.rb +1 -1
  63. data/lib/kitchen/terraform/deprecating.rb +1 -1
  64. data/lib/kitchen/terraform/driver/create.rb +39 -16
  65. data/lib/kitchen/terraform/driver/destroy.rb +53 -21
  66. data/lib/kitchen/terraform/driver.rb +1 -1
  67. data/lib/kitchen/terraform/error.rb +1 -1
  68. data/lib/kitchen/terraform/file_path_config_attribute_definer.rb +1 -1
  69. data/lib/kitchen/terraform/inspec/fail_fast_with_hosts.rb +1 -1
  70. data/lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb +1 -1
  71. data/lib/kitchen/terraform/inspec/without_hosts.rb +1 -1
  72. data/lib/kitchen/terraform/inspec.rb +1 -1
  73. data/lib/kitchen/terraform/inspec_factory.rb +1 -1
  74. data/lib/kitchen/terraform/inspec_options_factory.rb +1 -1
  75. data/lib/kitchen/terraform/inspec_runner.rb +5 -4
  76. data/lib/kitchen/terraform/outputs_manager.rb +1 -1
  77. data/lib/kitchen/terraform/outputs_parser.rb +1 -1
  78. data/lib/kitchen/terraform/outputs_reader.rb +2 -2
  79. data/lib/kitchen/terraform/provisioner/converge.rb +52 -25
  80. data/lib/kitchen/terraform/provisioner.rb +1 -1
  81. data/lib/kitchen/terraform/raise/action_failed.rb +1 -1
  82. data/lib/kitchen/terraform/raise/client_error.rb +1 -1
  83. data/lib/kitchen/terraform/raise.rb +1 -1
  84. data/lib/kitchen/terraform/shell_out.rb +6 -5
  85. data/lib/kitchen/terraform/system.rb +1 -1
  86. data/lib/kitchen/terraform/system_attrs_inputs_resolver.rb +1 -1
  87. data/lib/kitchen/terraform/system_attrs_outputs_resolver.rb +1 -1
  88. data/lib/kitchen/terraform/system_bastion_host_resolver.rb +1 -1
  89. data/lib/kitchen/terraform/system_hosts_resolver.rb +1 -1
  90. data/lib/kitchen/terraform/system_inspec_map.rb +1 -1
  91. data/lib/kitchen/terraform/systems_verifier/fail_fast.rb +1 -1
  92. data/lib/kitchen/terraform/systems_verifier/fail_slow.rb +1 -1
  93. data/lib/kitchen/terraform/systems_verifier.rb +1 -1
  94. data/lib/kitchen/terraform/systems_verifier_factory.rb +1 -1
  95. data/lib/kitchen/terraform/unsupported_client_version_error.rb +1 -1
  96. data/lib/kitchen/terraform/variables_manager.rb +1 -1
  97. data/lib/kitchen/terraform/verify_version.rb +5 -17
  98. data/lib/kitchen/terraform/verify_version_rescue_strategy/permissive.rb +1 -1
  99. data/lib/kitchen/terraform/verify_version_rescue_strategy/strict.rb +1 -1
  100. data/lib/kitchen/terraform/verify_version_rescue_strategy.rb +1 -1
  101. data/lib/kitchen/terraform/verify_version_rescue_strategy_factory.rb +1 -1
  102. data/lib/kitchen/terraform/version.rb +2 -2
  103. data/lib/kitchen/terraform/version_verifier.rb +1 -1
  104. data/lib/kitchen/terraform/version_verifier_strategy/supported.rb +1 -1
  105. data/lib/kitchen/terraform/version_verifier_strategy/unsupported.rb +1 -1
  106. data/lib/kitchen/terraform/version_verifier_strategy.rb +1 -1
  107. data/lib/kitchen/terraform/version_verifier_strategy_factory.rb +1 -1
  108. data/lib/kitchen/terraform.rb +1 -1
  109. data/lib/kitchen/verifier/terraform.rb +1 -1
  110. data.tar.gz.sig +0 -0
  111. metadata +65 -62
  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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d5a6c9922d2b53491977ad08e487e91ddc8af0532ae8024f791079ad827bd07
4
- data.tar.gz: bb1a42986e827b6fe4cf2f53826ef1b9b66c55921d2025f42df185ce2983f8ce
3
+ metadata.gz: 8549ab850779ffc15ccb46e62033077103d76ccc0a57b87ee30dd8de88838b70
4
+ data.tar.gz: c7f65d4ef1e3f37e7e1cd1d73e48b294517d5911292a787350749f7ef9a99d41
5
5
  SHA512:
6
- metadata.gz: e82db17864ab68a669da0b97e05747edf9a1317e367cd11fa271e26fdd1b04c2d4b53b66c1f72156bf9fd0ad336f891520cf52035b7ec06516d2b14671e149d8
7
- data.tar.gz: 46c0b1e9697e0ad7fd5855563b13ed0da6fdaaf3a00995072f76dac4d270e68102c5caa7fd562c30ca632f947b8c56f56137281ec7d30eea7aa181c5dc53ac2c
6
+ metadata.gz: daa80765cdb58cd956a4b42aee2c9bc86f40172bd349fdbb683727f6d3ac925b9347c4e22c9b5c89b62ebc8d8ff771e2ee0140dbd496407ac1910193918eb4a6
7
+ data.tar.gz: 33401e979b8f07aacfbcf206b9b9c721d08641920d0178334485a7c1a8359269552db38400886175c15a8c0f4dab1e3f88a277bbd1e1c06f52d44681cdb01d86
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
  [![Gem downloads version][gem-downloads-version-shield]][kitchen-terraform-gem]
7
7
  [![Gem downloads total][gem-downloads-total-shield]][kitchen-terraform-gem]
8
8
 
9
- [![Travis CI Build status][travis-build-status-shield]][travis-build-status]
10
- [![AppVeyor Build status][appveyor-build-status-shield]][appveyor-build-status]
9
+ [![Kitchen tests workflow][kitchen-tests-workflow-shield]][kitchen-tests-workflow]
10
+ [![RSpec tests workflow][rspec-tests-workflow-shield]][rspec-tests-workflow]
11
11
  [![Code coverage][code-coverage-shield]][code-coverage]
12
12
  [![Maintainability][maintainability-shield]][maintainability]
13
13
  [![Technical debt][technical-debt-shield]][technical-debt]
@@ -36,7 +36,7 @@ Installation instructions can be found in the
36
36
  [Terraform: Install Terraform][terraform-install] article.
37
37
 
38
38
  Kitchen-Terraform supports versions of Terraform in the interval of
39
- `>= 0.11.4, < 0.15.0`.
39
+ `>= 0.11.4, < 2.0.0`.
40
40
 
41
41
  [tfenv] can be used to manage versions of Terraform on the system.
42
42
 
@@ -102,7 +102,7 @@ example.
102
102
  > Installing Kitchen-Terraform with RubyGems
103
103
 
104
104
  ```sh
105
- gem install kitchen-terraform --version 5.7.1
105
+ gem install kitchen-terraform --version 6.1.0
106
106
  ```
107
107
 
108
108
  This approach is not recommended as it requires more effort to install
@@ -182,43 +182,43 @@ Information about changes to Kitchen-Terraform can be found in the
182
182
  ## Maintainers
183
183
 
184
184
  Kitchen-Terraform is maintained by [community contributors][contributors]
185
- and New Context.
185
+ and Copado NCS LLC.
186
186
 
187
187
  <img
188
- alt="New Context logo"
188
+ alt="Copado logo"
189
189
  height="25"
190
- src="https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/new_context_logo.png"
191
- width="25"> [NewContext.com][new-context]
190
+ src="https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/copado_logo.png"
191
+ width="25"> [copado.com][copado]
192
192
 
193
193
  <img
194
194
  alt="Twitter logo"
195
195
  height="25"
196
196
  src="https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/twitter_logo.png"
197
- width="25"> [@NewContext][new-context-twitter]
197
+ width="25"> [@CopadoSolutions][copado-twitter]
198
198
 
199
199
  <img
200
200
  alt="LinkedIn logo"
201
201
  height="23"
202
202
  src="https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/linkedin_logo.png"
203
- width="25"> [New Context][new-context-linkedin]
203
+ width="25"> [Copado][copado-linkedin]
204
204
 
205
205
  <img
206
206
  alt="GitHub logo"
207
207
  height="25"
208
208
  src="https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/github_logo.png"
209
- width="25"> [@NewContext][new-context-github]
209
+ width="25"> [@CopadoSolutions][copado-github]
210
210
 
211
211
  <img
212
212
  alt="Email logo"
213
213
  height="16"
214
214
  src="https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/email_logo.png"
215
- width="25"> kitchen-terraform@newcontext.com
215
+ width="25"> kitchen-terraform@copado.com
216
216
 
217
217
  <img
218
218
  alt="Email logo"
219
219
  height="16"
220
220
  src="https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/email_logo.png"
221
- width="25"> info@newcontext.com
221
+ width="25"> ss-info@copado.com
222
222
 
223
223
  ## License
224
224
 
@@ -254,15 +254,19 @@ Kitchen-Terraform is distributed under the [Apache License][license].
254
254
  [kitchen-terraform-gem]: https://rubygems.org/gems/kitchen-terraform
255
255
  [kitchen-terraform-logo]: https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/logo.png
256
256
  [kitchen-terraform-tutorials]: https://newcontext-oss.github.io/kitchen-terraform/tutorials/
257
+ [kitchen-tests-workflow]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/kitchen-tests.yml
258
+ [kitchen-tests-workflow-shield]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/kitchen-tests.yml/badge.svg
257
259
  [license]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/LICENSE
258
260
  [maintainability-shield]: https://img.shields.io/codeclimate/maintainability-percentage/newcontext-oss/kitchen-terraform.svg
259
261
  [maintainability]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/
260
- [new-context-github]: https://github.com/newcontext
261
- [new-context-linkedin]: https://www.linkedin.com/company/-new-context-
262
- [new-context-twitter]: https://twitter.com/newcontext
263
- [new-context]: https://newcontext.com/
262
+ [copado-github]: https://github.com/CopadoSolutions
263
+ [copado-linkedin]: https://www.linkedin.com/company/copado-solutions-s.l
264
+ [copado-twitter]: https://twitter.com/CopadoSolutions
265
+ [copado]: https://copado.com/
264
266
  [rbenv]: https://github.com/rbenv/rbenv
265
267
  [rbnacl-installation]: https://github.com/crypto-rb/rbnacl/tree/v4.0.2#installation
268
+ [rspec-tests-workflow]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/rspec-tests.yml
269
+ [rspec-tests-workflow-shield]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/rspec-tests.yml/badge.svg
266
270
  [ruby-branches]: https://www.ruby-lang.org/en/downloads/branches/
267
271
  [ruby-gem-documentation]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/
268
272
  [ruby-gems-what-is]: http://guides.rubygems.org/ruby-gems-what-is/index.html
@@ -279,5 +283,3 @@ Kitchen-Terraform is distributed under the [Apache License][license].
279
283
  [terraform]: https://www.terraform.io/
280
284
  [test-directory]: https://github.com/newcontext-oss/kitchen-terraform/tree/master/test
281
285
  [tfenv]: https://github.com/kamatama41/tfenv
282
- [travis-build-status-shield]: https://img.shields.io/travis/com/newcontext-oss/kitchen-terraform.svg
283
- [travis-build-status]: https://travis-ci.com/newcontext-oss/kitchen-terraform
@@ -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.
@@ -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.
@@ -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.
@@ -0,0 +1,89 @@
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 "kitchen/terraform/command_flag/backend_config"
18
+ require "kitchen/terraform/command_flag/color"
19
+ require "kitchen/terraform/command_flag/lock_timeout"
20
+ require "kitchen/terraform/command_flag/plugin_dir"
21
+ require "kitchen/terraform/command_flag/upgrade"
22
+
23
+ module Kitchen
24
+ module Terraform
25
+ module Command
26
+ module Init
27
+ # The working directory is initialized by running a command like the following example:
28
+ # terraform init \
29
+ # -backend=true \
30
+ # [-backend-config=<backend_configurations[0]> ...] \
31
+ # -force-copy \
32
+ # -get=true \
33
+ # -input=false \
34
+ # [-no-color] \
35
+ # [-plugin-dir=<plugin_directory>] \
36
+ # [-upgrade=true] \
37
+ # <root_module_directory>
38
+ class PostZeroFifteenZero
39
+ # #initialize prepares a new instance of the class.
40
+ #
41
+ # @param config [Hash] the configuration of the driver.
42
+ # @option config [Hash{String=>String}] :backend_configurations Terraform backend configuration arguments to
43
+ # complete a partial backend configuration.
44
+ # @option config [Boolean] :color a toggle of colored output from the Terraform client.
45
+ # on the state to be obtained during operations.
46
+ # @option config [String] :plugin_directory the pathname of the directory which contains
47
+ # customized Terraform provider plugins to install in place of the official Terraform provider plugins.
48
+ # @option config [Boolean] :upgrade_during_init a toggle for upgrading modules and plugins.
49
+ # @return [Kitchen::Terraform::Command::Init::PostZeroFifteenZero]
50
+ def initialize(config:)
51
+ self.backend_config = ::Kitchen::Terraform::CommandFlag::BackendConfig.new arguments: config.fetch(
52
+ :backend_configurations
53
+ )
54
+ self.color = ::Kitchen::Terraform::CommandFlag::Color.new enabled: config.fetch(:color)
55
+ self.plugin_dir = ::Kitchen::Terraform::CommandFlag::PluginDir.new pathname: config.fetch(
56
+ :plugin_directory
57
+ )
58
+ self.upgrade = ::Kitchen::Terraform::CommandFlag::Upgrade.new enabled: config.fetch(:upgrade_during_init)
59
+ end
60
+
61
+ # @return [String] the command with flags.
62
+ def to_s
63
+ "init " \
64
+ "-backend=true " \
65
+ "#{backend_config} " \
66
+ "-force-copy=true " \
67
+ "-get=true " \
68
+ "-input=false " \
69
+ "#{color} " \
70
+ "#{plugin_dir} " \
71
+ "#{upgrade}"
72
+ end
73
+
74
+ private
75
+
76
+ attr_accessor(
77
+ :backend_config,
78
+ :color,
79
+ :lock,
80
+ :lock_timeout,
81
+ :options,
82
+ :plugin_dir,
83
+ :upgrade,
84
+ )
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,101 @@
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 "kitchen/terraform/command_flag/backend_config"
18
+ require "kitchen/terraform/command_flag/color"
19
+ require "kitchen/terraform/command_flag/lock_timeout"
20
+ require "kitchen/terraform/command_flag/plugin_dir"
21
+ require "kitchen/terraform/command_flag/upgrade"
22
+
23
+ module Kitchen
24
+ module Terraform
25
+ module Command
26
+ module Init
27
+ # The working directory is initialized by running a command like the following example:
28
+ # terraform init \
29
+ # -backend=true \
30
+ # [-backend-config=<backend_configurations[0]> ...] \
31
+ # -force-copy \
32
+ # -get=true \
33
+ # -get-plugins=true \
34
+ # -input=false \
35
+ # -lock=<lock> \
36
+ # -lock-timeout=<lock_timeout>s \
37
+ # [-no-color] \
38
+ # [-plugin-dir=<plugin_directory>] \
39
+ # [-upgrade=true] \
40
+ # -verify-plugins=true \
41
+ # <root_module_directory>
42
+ class PreZeroFifteenZero
43
+ # #initialize prepares a new instance of the class.
44
+ #
45
+ # @param config [Hash] the configuration of the driver.
46
+ # @option config [Hash{String=>String}] :backend_configurations Terraform backend configuration arguments to
47
+ # complete a partial backend configuration.
48
+ # @option config [Boolean] :color a toggle of colored output from the Terraform client.
49
+ # @option config [Boolean] :lock a toggle of locking for the Terraform state file.
50
+ # @option config [Integer] :lock_timeout the number of seconds that the Terraform client will wait for a lock
51
+ # on the state to be obtained during operations.
52
+ # @option config [String] :plugin_directory the pathname of the directory which contains
53
+ # customized Terraform provider plugins to install in place of the official Terraform provider plugins.
54
+ # @option config [Boolean] :upgrade_during_init a toggle for upgrading modules and plugins.
55
+ # @return [Kitchen::Terraform::Command::Init::PreZeroFifteenZero]
56
+ def initialize(config:)
57
+ self.backend_config = ::Kitchen::Terraform::CommandFlag::BackendConfig.new arguments: config.fetch(
58
+ :backend_configurations
59
+ )
60
+ self.color = ::Kitchen::Terraform::CommandFlag::Color.new enabled: config.fetch(:color)
61
+ self.lock = config.fetch :lock
62
+ self.lock_timeout = ::Kitchen::Terraform::CommandFlag::LockTimeout.new duration: config.fetch(:lock_timeout)
63
+ self.plugin_dir = ::Kitchen::Terraform::CommandFlag::PluginDir.new pathname: config.fetch(
64
+ :plugin_directory
65
+ )
66
+ self.upgrade = ::Kitchen::Terraform::CommandFlag::Upgrade.new enabled: config.fetch(:upgrade_during_init)
67
+ end
68
+
69
+ # @return [String] the command with flags.
70
+ def to_s
71
+ "init " \
72
+ "-backend=true " \
73
+ "#{backend_config} " \
74
+ "-force-copy=true " \
75
+ "-get=true " \
76
+ "-get-plugins=true " \
77
+ "-input=false " \
78
+ "-lock=#{lock} " \
79
+ "#{lock_timeout} " \
80
+ "#{color} " \
81
+ "#{plugin_dir} " \
82
+ "#{upgrade} " \
83
+ "-verify-plugins=true"
84
+ end
85
+
86
+ private
87
+
88
+ attr_accessor(
89
+ :backend_config,
90
+ :color,
91
+ :lock,
92
+ :lock_timeout,
93
+ :options,
94
+ :plugin_dir,
95
+ :upgrade,
96
+ )
97
+ end
98
+ end
99
+ end
100
+ end
101
+ 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,88 +14,11 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require "kitchen/terraform/command_flag/backend_config"
18
- require "kitchen/terraform/command_flag/color"
19
- require "kitchen/terraform/command_flag/lock_timeout"
20
- require "kitchen/terraform/command_flag/plugin_dir"
21
- require "kitchen/terraform/command_flag/upgrade"
22
-
23
17
  module Kitchen
24
18
  module Terraform
25
19
  module Command
26
- # The working directory is initialized by running a command like the following example:
27
- # terraform init \
28
- # -input=false \
29
- # -lock=<lock> \
30
- # -lock-timeout=<lock_timeout>s \
31
- # [-no-color] \
32
- # [-upgrade] \
33
- # -force-copy \
34
- # -backend=true \
35
- # [-backend-config=<backend_configurations[0]> ...] \
36
- # -get=true \
37
- # -get-plugins=true \
38
- # [-plugin-dir=<plugin_directory>] \
39
- # -verify-plugins=true \
40
- # <root_module_directory>
41
- class Init
42
- # #initialize prepares a new instance of the class.
43
- #
44
- # @param config [Hash] the configuration of the driver.
45
- # @option config [Hash{String=>String}] :backend_configurations Terraform backend configuration arguments to
46
- # complete a partial backend configuration.
47
- # @option config [Boolean] :color a toggle of colored output from the Terraform client.
48
- # @option config [Integer] :command_timeout the the number of seconds to wait for the command to finish running.
49
- # @option config [Boolean] :lock a toggle of locking for the Terraform state file.
50
- # @option config [Integer] :lock_timeout the number of seconds that the Terraform client will wait for a lock
51
- # on the state to be obtained during operations.
52
- # @option config [String] :plugin_directory the pathname of the directory which contains
53
- # customized Terraform provider plugins to install in place of the official Terraform provider plugins.
54
- # @option config [String] :root_module_directory the pathname of the directory which contains the root
55
- # Terraform module.
56
- # @option config [Boolean] :upgrade_during_init a toggle for upgrading modules and plugins.
57
- # @return [Kitchen::Terraform::Command::Init]
58
- def initialize(config:)
59
- self.backend_config = ::Kitchen::Terraform::CommandFlag::BackendConfig.new arguments: config.fetch(
60
- :backend_configurations
61
- )
62
- self.color = ::Kitchen::Terraform::CommandFlag::Color.new enabled: config.fetch(:color)
63
- self.lock = config.fetch :lock
64
- self.lock_timeout = ::Kitchen::Terraform::CommandFlag::LockTimeout.new duration: config.fetch(:lock_timeout)
65
- self.plugin_dir = ::Kitchen::Terraform::CommandFlag::PluginDir.new pathname: config.fetch(
66
- :plugin_directory
67
- )
68
- self.upgrade = ::Kitchen::Terraform::CommandFlag::Upgrade.new enabled: config.fetch(:upgrade_during_init)
69
- end
70
-
71
- # @return [String] the command with flags.
72
- def to_s
73
- "init " \
74
- "-input=false " \
75
- "-lock=#{lock} " \
76
- "#{lock_timeout} " \
77
- "#{color} " \
78
- "#{upgrade} " \
79
- "-force-copy " \
80
- "-backend=true " \
81
- "#{backend_config} " \
82
- "-get=true " \
83
- "-get-plugins=true " \
84
- "#{plugin_dir} " \
85
- "-verify-plugins=true"
86
- end
87
-
88
- private
89
-
90
- attr_accessor(
91
- :backend_config,
92
- :color,
93
- :lock,
94
- :lock_timeout,
95
- :options,
96
- :plugin_dir,
97
- :upgrade,
98
- )
20
+ # Init is the namespace for Terraform Init commands.
21
+ module Init
99
22
  end
100
23
  end
101
24
  end
@@ -0,0 +1,52 @@
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 "kitchen/terraform/command/init/post_zero_fifteen_zero"
18
+ require "kitchen/terraform/command/init/pre_zero_fifteen_zero"
19
+ require "rubygems"
20
+
21
+ module Kitchen
22
+ module Terraform
23
+ module Command
24
+ # InitFactory is the class of objects which build Init objects.
25
+ class InitFactory
26
+ # #build creates a new instance of an Init object.
27
+ #
28
+ # @param config [Hash] the configuration of the driver.
29
+ # @return [Kitchen::Terraform::Command::Init::PreZeroFifteenZero,
30
+ # Kitchen::Terraform::Command::Init::PostZeroFifteenZero]
31
+ def build(config:)
32
+ return ::Kitchen::Terraform::Command::Init::PreZeroFifteenZero.new config: config if requirement.satisfied_by? version
33
+
34
+ ::Kitchen::Terraform::Command::Init::PostZeroFifteenZero.new config: config
35
+ end
36
+
37
+ # #initialize prepares a new instance of the class
38
+ #
39
+ # @param version [Gem::Version] a client version.
40
+ # @return [Kitchen::Terraform::Command::InitFactory]
41
+ def initialize(version:)
42
+ self.requirement = ::Gem::Requirement.new "< 0.15.0"
43
+ self.version = version
44
+ end
45
+
46
+ private
47
+
48
+ attr_accessor :requirement, :version
49
+ end
50
+ end
51
+ end
52
+ 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.
@@ -0,0 +1,51 @@
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 "kitchen/terraform/command_flag/color"
18
+ require "shellwords"
19
+
20
+ module Kitchen
21
+ module Terraform
22
+ module Command
23
+ module Validate
24
+ # The root module is validated by running a command like the following example:
25
+ # terraform validate \
26
+ # [-no-color] \
27
+ # <directory>
28
+ class PostZeroFifteenZero
29
+ # #initialize prepares a new instance of the class.
30
+ #
31
+ # @param config [Hash] the configuration of the driver.
32
+ # @option config [Boolean] :color a toggle of colored output from the Terraform client.
33
+ # @return [Kitchen::Terraform::Command::Validate]
34
+ def initialize(config:)
35
+ self.color = ::Kitchen::Terraform::CommandFlag::Color.new enabled: config.fetch(:color)
36
+ end
37
+
38
+ # @return [String] the command with flags.
39
+ def to_s
40
+ "validate " \
41
+ "#{color}"
42
+ end
43
+
44
+ private
45
+
46
+ attr_accessor :color
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,65 @@
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 "kitchen/terraform/command_flag/color"
18
+ require "kitchen/terraform/command_flag/var_file"
19
+ require "kitchen/terraform/command_flag/var"
20
+ require "shellwords"
21
+
22
+ module Kitchen
23
+ module Terraform
24
+ module Command
25
+ module Validate
26
+ # The root module is validated by running a command like the following example:
27
+ # terraform validate \
28
+ # [-no-color] \
29
+ # [-var=<variables.first>...] \
30
+ # [-var-file=<variable_files.first>...] \
31
+ # <directory>
32
+ class PreZeroFifteenZero
33
+ # #initialize prepares a new instance of the class.
34
+ #
35
+ # @param config [Hash] the configuration of the driver.
36
+ # @option config [Boolean] :color a toggle of colored output from the Terraform client.
37
+ # @option config [Array<String>] :variable_files a list of pathnames of Terraform variable files to evaluate.
38
+ # @option config [Hash{String=>String}] :variables a mapping of Terraform variables to evaluate.
39
+ # @return [Kitchen::Terraform::Command::Validate]
40
+ def initialize(config:)
41
+ self.color = ::Kitchen::Terraform::CommandFlag::Color.new enabled: config.fetch(:color)
42
+ self.var_file = ::Kitchen::Terraform::CommandFlag::VarFile.new pathnames: config.fetch(:variable_files)
43
+ self.var = ::Kitchen::Terraform::CommandFlag::Var.new arguments: config.fetch(:variables)
44
+ end
45
+
46
+ # @return [String] the command with flags.
47
+ def to_s
48
+ "validate " \
49
+ "#{color} " \
50
+ "#{var} " \
51
+ "#{var_file}"
52
+ end
53
+
54
+ private
55
+
56
+ attr_accessor(
57
+ :color,
58
+ :var_file,
59
+ :var,
60
+ )
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end