kitchen-terraform 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +3 -1
  4. data/README.md +33 -359
  5. data/lib/kitchen/driver/terraform.rb +273 -57
  6. data/lib/kitchen/driver/terraform/verify_client_version.rb +44 -0
  7. data/lib/kitchen/driver/terraform/workflow.rb +90 -0
  8. data/lib/kitchen/provisioner/terraform.rb +31 -37
  9. data/lib/{terraform/get_command.rb → kitchen/terraform.rb} +3 -5
  10. data/lib/{terraform/deprecated_version.rb → kitchen/terraform/client.rb} +5 -12
  11. data/lib/kitchen/terraform/client/apply.rb +38 -0
  12. data/lib/kitchen/terraform/client/execute_command.rb +56 -0
  13. data/lib/kitchen/terraform/client/get.rb +35 -0
  14. data/lib/kitchen/terraform/client/output.rb +50 -0
  15. data/lib/kitchen/terraform/client/plan.rb +42 -0
  16. data/lib/kitchen/terraform/client/process_options.rb +87 -0
  17. data/lib/kitchen/terraform/client/validate.rb +35 -0
  18. data/lib/kitchen/terraform/client/version.rb +48 -0
  19. data/lib/{terraform/apply_timeout_config.rb → kitchen/terraform/create_directories.rb} +18 -11
  20. data/lib/kitchen/terraform/define_config_attribute.rb +39 -0
  21. data/lib/kitchen/terraform/define_integer_config_attribute.rb +43 -0
  22. data/lib/kitchen/terraform/define_string_config_attribute.rb +43 -0
  23. data/lib/kitchen/verifier/terraform.rb +186 -38
  24. data/lib/kitchen/verifier/terraform/configure_inspec_runner_attributes.rb +93 -0
  25. data/lib/kitchen/verifier/terraform/configure_inspec_runner_backend.rb +32 -0
  26. data/lib/kitchen/verifier/terraform/configure_inspec_runner_controls.rb +39 -0
  27. data/lib/{terraform/apply_command.rb → kitchen/verifier/terraform/configure_inspec_runner_host.rb} +11 -15
  28. data/lib/{terraform/deprecated_output_parser.rb → kitchen/verifier/terraform/configure_inspec_runner_port.rb} +16 -20
  29. data/lib/{terraform/deprecated_variables_coercer.rb → kitchen/verifier/terraform/configure_inspec_runner_user.rb} +16 -14
  30. data/lib/kitchen/verifier/terraform/enumerate_groups_and_hostnames.rb +67 -0
  31. data/lib/{terraform/version_command.rb → terraform.rb} +1 -5
  32. data/lib/terraform/configurable.rb +18 -61
  33. data/lib/terraform/debug_logger.rb +12 -12
  34. data/lib/terraform/project_version.rb +1 -1
  35. metadata +72 -135
  36. metadata.gz.sig +0 -0
  37. data/lib/terraform/cli_config.rb +0 -29
  38. data/lib/terraform/client.rb +0 -96
  39. data/lib/terraform/color_coercer.rb +0 -35
  40. data/lib/terraform/color_config.rb +0 -32
  41. data/lib/terraform/command.rb +0 -53
  42. data/lib/terraform/command_factory.rb +0 -111
  43. data/lib/terraform/command_option.rb +0 -65
  44. data/lib/terraform/command_options.rb +0 -103
  45. data/lib/terraform/destructive_plan_command.rb +0 -35
  46. data/lib/terraform/directory_config.rb +0 -32
  47. data/lib/terraform/file_configs.rb +0 -36
  48. data/lib/terraform/group.rb +0 -61
  49. data/lib/terraform/group_attributes.rb +0 -42
  50. data/lib/terraform/group_hostnames.rb +0 -38
  51. data/lib/terraform/groups_coercer.rb +0 -43
  52. data/lib/terraform/groups_config.rb +0 -32
  53. data/lib/terraform/integer_coercer.rb +0 -37
  54. data/lib/terraform/no_output_parser.rb +0 -28
  55. data/lib/terraform/output_command.rb +0 -23
  56. data/lib/terraform/output_parser.rb +0 -55
  57. data/lib/terraform/parallelism_config.rb +0 -32
  58. data/lib/terraform/pathname_coercer.rb +0 -40
  59. data/lib/terraform/plan_command.rb +0 -30
  60. data/lib/terraform/prepare_input_file.rb +0 -34
  61. data/lib/terraform/prepare_output_file.rb +0 -36
  62. data/lib/terraform/shell_out.rb +0 -59
  63. data/lib/terraform/show_command.rb +0 -30
  64. data/lib/terraform/simple_coercer.rb +0 -36
  65. data/lib/terraform/simple_config.rb +0 -28
  66. data/lib/terraform/unsupported_version.rb +0 -26
  67. data/lib/terraform/validate_command.rb +0 -23
  68. data/lib/terraform/variable_files_coercer.rb +0 -40
  69. data/lib/terraform/variable_files_config.rb +0 -32
  70. data/lib/terraform/variables_coercer.rb +0 -49
  71. data/lib/terraform/variables_config.rb +0 -32
  72. data/lib/terraform/version.rb +0 -73
@@ -0,0 +1,44 @@
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/monads"
18
+ require "kitchen/driver/terraform"
19
+
20
+ # Verifies that the provided Terraform Client version is supported.
21
+ #
22
+ # Supported:: Terraform version 0.9.
23
+ #
24
+ # Deprecated:: Terraform versions 0.7 and 0.8.
25
+ #
26
+ # Not Supported:: Terraform versions 0.6 and older.
27
+ module ::Kitchen::Driver::Terraform::VerifyClientVersion
28
+ extend ::Dry::Monads::Either::Mixin
29
+
30
+ # Invokes the function.
31
+ #
32
+ # @param version [::Float] the Terraform Client version.
33
+ # @return [::Dry::Monads::Either] the result of the function.
34
+ def self.call(version:)
35
+ if version == 0.9
36
+ Right "Terraform version #{version} is supported"
37
+ elsif (0.7..0.8).cover? version
38
+ Right "Terraform version #{version} is deprecated and will not be supported by kitchen-terraform version " \
39
+ "2.0; upgrade to Terraform version 0.9 to remain supported"
40
+ else
41
+ Left "Terraform version #{version} is not supported; supported Terraform versions are 0.7 through 0.9"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,90 @@
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/monads"
18
+ require "kitchen/driver/terraform"
19
+ require "kitchen/terraform/client/apply"
20
+ require "kitchen/terraform/client/get"
21
+ require "kitchen/terraform/client/validate"
22
+ require "kitchen/terraform/create_directories"
23
+
24
+ # Creates the directories to contain the root Terraform module, the Terraform execution plan, and the Terraform state,
25
+ # then validates the Terraform configuration, updates any Terraform dependencies, and applies a constructive or
26
+ # destructive Terraform execution plan to the Terraform state.
27
+ module ::Kitchen::Driver::Terraform::Workflow
28
+ extend ::Dry::Monads::Either::Mixin
29
+
30
+ # Invokes the function.
31
+ #
32
+ # @param config [::Kitchen::Config] the configuration of the kitchen-terraform driver.
33
+ # @param destroy [::TrueClass, ::FalseClass] the flag that controls constructive or destructive planning.
34
+ # @param logger [#<<] a logger to receive the execution output of the Terraform Client functions.
35
+ # @return [::Dry::Monads::Either] the result of the function.
36
+ # @see ::Kitchen::Terraform::Client::Apply
37
+ # @see ::Kitchen::Terraform::Client::Get
38
+ # @see ::Kitchen::Terraform::Client::Plan
39
+ # @see ::Kitchen::Terraform::Client::Validate
40
+ # @see ::Kitchen::Terraform::CreateDirectories
41
+ def self.call(config:, destroy: false, logger:)
42
+ ::Kitchen::Terraform::CreateDirectories.call(
43
+ directories: [
44
+ config.fetch(:directory),
45
+ ::File.dirname(config.fetch(:plan)),
46
+ ::File.dirname(config.fetch(:state))
47
+ ]
48
+ ).fmap do |created_directories|
49
+ logger.debug created_directories
50
+ end.bind do
51
+ ::Kitchen::Terraform::Client::Validate.call cli: config.fetch(:cli),
52
+ directory: config.fetch(:directory),
53
+ logger: logger,
54
+ timeout: config.fetch(:command_timeout)
55
+ end.bind do
56
+ ::Kitchen::Terraform::Client::Get.call cli: config.fetch(:cli),
57
+ logger: logger,
58
+ root_module: config.fetch(:directory),
59
+ timeout: config.fetch(:command_timeout)
60
+ end.bind do
61
+ ::Kitchen::Terraform::Client::Plan.call cli: config.fetch(:cli),
62
+ logger: logger,
63
+ options: {
64
+ color: config.fetch(:color),
65
+ destroy: destroy,
66
+ out: config.fetch(:plan),
67
+ parallelism: config.fetch(:parallelism),
68
+ state: config.fetch(:state),
69
+ var: config.fetch(:variables),
70
+ var_file: config.fetch(:variable_files)
71
+ },
72
+ root_module: config.fetch(:directory),
73
+ timeout: config.fetch(:command_timeout)
74
+ end.bind do
75
+ ::Kitchen::Terraform::Client::Apply.call cli: config.fetch(:cli),
76
+ logger: logger,
77
+ options: {
78
+ color: config.fetch(:color),
79
+ parallelism: config.fetch(:parallelism),
80
+ state_out: config.fetch(:state)
81
+ },
82
+ plan: config.fetch(:plan),
83
+ timeout: config.fetch(:command_timeout)
84
+ end.fmap do
85
+ "driver workflow was a success"
86
+ end.or do |error|
87
+ Left "driver workflow was a failure\n#{error}"
88
+ end
89
+ end
90
+ end
@@ -14,43 +14,37 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require 'kitchen'
18
- require 'terraform/apply_timeout_config'
19
- require 'terraform/color_config'
20
- require 'terraform/configurable'
21
- require 'terraform/directory_config'
22
- require 'terraform/file_configs'
23
- require 'terraform/parallelism_config'
24
- require 'terraform/variable_files_config'
25
- require 'terraform/variables_config'
17
+ require "kitchen"
18
+ require "terraform/configurable"
26
19
 
27
- module Kitchen
28
- module Provisioner
29
- # Applies constructive Terraform plans
30
- class Terraform < ::Kitchen::Provisioner::Base
31
- extend ::Terraform::ApplyTimeoutConfig
32
-
33
- extend ::Terraform::ColorConfig
34
-
35
- extend ::Terraform::DirectoryConfig
36
-
37
- extend ::Terraform::FileConfigs
38
-
39
- extend ::Terraform::ParallelismConfig
40
-
41
- extend ::Terraform::VariableFilesConfig
42
-
43
- extend ::Terraform::VariablesConfig
44
-
45
- include ::Terraform::Configurable
46
-
47
- kitchen_provisioner_api_version 2
48
-
49
- def call(_state = nil)
50
- client.apply_constructively
51
- rescue ::Kitchen::StandardError, ::SystemCallError => error
52
- raise ::Kitchen::ActionFailed, error.message
53
- end
54
- end
20
+ # The design of the provisioner is unconventional compared to other Test Kitchen provisioner plugins. Since Terraform
21
+ # creates and provisions resources when applying an execution plan, managed by the driver, the provisioner simply
22
+ # proxies the driver's create action to apply any changes to the existing Terraform state.
23
+ #
24
+ # === Configuration
25
+ #
26
+ # ==== Example .kitchen.yml snippet
27
+ #
28
+ # provisioner:
29
+ # name: terraform
30
+ #
31
+ # @see ::Kitchen::Driver::Terraform
32
+ # @see https://www.terraform.io/docs/commands/plan.html Terraform execution plan
33
+ # @see https://www.terraform.io/docs/state/index.html Terraform state
34
+ # @version 2
35
+ class ::Kitchen::Provisioner::Terraform < ::Kitchen::Provisioner::Base
36
+ kitchen_provisioner_api_version 2
37
+
38
+ include ::Terraform::Configurable
39
+
40
+ # Proxies the driver's create action.
41
+ #
42
+ # @example
43
+ # `kitchen converge suite-name`
44
+ # @param state [::Hash] the mutable instance and provisioner state.
45
+ # @raise [::Kitchen::ActionFailed] if the result of the action is a failure.
46
+ # @return [::Dry::Monads::Either] the result of the action.
47
+ def call(state)
48
+ instance.driver.create state
55
49
  end
56
50
  end
@@ -14,10 +14,8 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require 'terraform/command'
17
+ require "kitchen"
18
18
 
19
- module Terraform
20
- # A command to get dependency modules
21
- class GetCommand < ::Terraform::Command
22
- end
19
+ # The namespace for kitchen-terraform.
20
+ module ::Kitchen::Terraform
23
21
  end
@@ -14,17 +14,10 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require 'delegate'
17
+ require "kitchen/terraform"
18
18
 
19
- module Terraform
20
- # A deprecated version of Terraform
21
- class DeprecatedVersion < ::SimpleDelegator
22
- def if_deprecated
23
- yield
24
- end
25
-
26
- def if_json_not_supported
27
- yield
28
- end
29
- end
19
+ # The namespace for functions that wrap the Terraform command-line interface (CLI) commands.
20
+ #
21
+ # @see https://www.terraform.io/docs/commands/index.html Terraform CLI
22
+ module ::Kitchen::Terraform::Client
30
23
  end
@@ -0,0 +1,38 @@
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/client"
18
+ require "kitchen/terraform/client/execute_command"
19
+
20
+ # Applies the the pre-determined set of actions generated by a Terraform execution plan.
21
+ #
22
+ # @see https://www.terraform.io/docs/commands/apply.html Terraform apply command
23
+ # @see https://www.terraform.io/docs/commands/plan.html Terraform plan command
24
+ module ::Kitchen::Terraform::Client::Apply
25
+ # Invokes the function.
26
+ #
27
+ # @param cli [::String] the path of the Terraform CLI to use to execute the apply command.
28
+ # @param logger [#<<] a logger to receive the stdout and stderr of the apply command.
29
+ # @param options [::Hash] the options for the apply command.
30
+ # @param plan [::String] the path of the Terraform execution plan to apply.
31
+ # @param timeout [::Integer] the maximum execution time in seconds for the apply command.
32
+ # @return [::Dry::Monads::Either] the result of the function.
33
+ def self.call(cli:, logger:, options:, plan:, timeout:)
34
+ ::Kitchen::Terraform::Client::ExecuteCommand.call cli: cli, command: "apply", logger: logger,
35
+ options: options.merge(input: false), target: plan,
36
+ timeout: timeout
37
+ end
38
+ end
@@ -0,0 +1,56 @@
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/monads"
18
+ require "kitchen/terraform/client"
19
+ require "kitchen/terraform/client/process_options"
20
+ require "mixlib/shellout"
21
+
22
+ # Executes Terraform commands.
23
+ #
24
+ # @see https://www.terraform.io/docs/commands/index.html Terraform commands
25
+ module ::Kitchen::Terraform::Client::ExecuteCommand
26
+ extend ::Dry::Monads::Either::Mixin
27
+
28
+ extend ::Dry::Monads::Try::Mixin
29
+
30
+ # Invokes the function.
31
+ #
32
+ # @param cli [::String] the path of the Terraform CLI to use for command execution.
33
+ # @param command [::String] the name of the command to execute.
34
+ # @param logger [#<<] a logger to receive the stdout and stderr of the command.
35
+ # @param options [::Hash] the options for the command.
36
+ # @param target [::String] the target of the command.
37
+ # @param timeout [::Integer] the maximum execution time in seconds for the command.
38
+ # @return [::Dry::Monads::Either] the result of the function.
39
+ def self.call(cli:, command:, logger:, options: {}, target: "", timeout:)
40
+ ::Kitchen::Terraform::Client::ProcessOptions.call(unprocessed_options: options).fmap do |processed_options|
41
+ ::Mixlib::ShellOut.new [cli, command, *processed_options, target].join(" ").strip,
42
+ live_stream: logger, timeout: timeout
43
+ end.bind do |shell_out|
44
+ Try ::Errno::EACCES, ::Errno::ENOENT, ::Mixlib::ShellOut::CommandTimeout do
45
+ shell_out.run_command
46
+ end
47
+ end.bind do |shell_out|
48
+ Try ::Mixlib::ShellOut::ShellCommandFailed do
49
+ shell_out.error!
50
+ shell_out
51
+ end
52
+ end.to_either.fmap(&:stdout).or do |error|
53
+ Left "`#{cli} #{command} #{target}` failed: '#{error}'"
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,35 @@
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/client"
18
+ require "kitchen/terraform/client/execute_command"
19
+
20
+ # Downloads and updates modules mentioned in the root Terraform module.
21
+ #
22
+ # @see https://www.terraform.io/docs/commands/get.html Terraform get command
23
+ module ::Kitchen::Terraform::Client::Get
24
+ # Invokes the function.
25
+ #
26
+ # @param cli [::String] the path of the Terraform CLI to use to execute the get command.
27
+ # @param logger [#<<] a logger to receive the stdour and stderr of the get command.
28
+ # @param root_module [::String] the path of the root module.
29
+ # @param timeout [::Integer] the maximum execution time in seconds for the get command.
30
+ # @return [::Dry::Monads::Either] the result of the function.
31
+ def self.call(cli:, logger:, root_module:, timeout:)
32
+ ::Kitchen::Terraform::Client::ExecuteCommand.call cli: cli, command: "get", logger: logger, options: {update: true},
33
+ target: root_module, timeout: timeout
34
+ end
35
+ end
@@ -0,0 +1,50 @@
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/monads"
18
+ require "json"
19
+ require "kitchen/terraform/client"
20
+ require "kitchen/terraform/client/execute_command"
21
+
22
+ # Extracts the values of Terraform output variables from a Terraform state.
23
+ #
24
+ # @see https://www.terraform.io/docs/commands/output.html Terraform output command
25
+ # @see https://www.terraform.io/docs/configuration/outputs.html Terraform output variables
26
+ # @see https://www.terraform.io/docs/state/index.html Terraform state
27
+ module ::Kitchen::Terraform::Client::Output
28
+ extend ::Dry::Monads::Either::Mixin
29
+
30
+ extend ::Dry::Monads::Try::Mixin
31
+
32
+ # Invokes the function.
33
+ #
34
+ # @param cli [::String] the path of the Terraform CLI to use to execute the output command.
35
+ # @param logger [#<<] a logger to receive the stdout and stderr of the output command.
36
+ # @param options [::Hash] the options for the output command.
37
+ # @param timeout [::Integer] the maximum execution time in seconds for the output command.
38
+ # @return [::Dry::Monads::Either] the result of the function.
39
+ def self.call(cli:, logger:, options:, timeout:)
40
+ ::Kitchen::Terraform::Client::ExecuteCommand
41
+ .call(cli: cli, command: "output", logger: logger, options: options.merge(json: true), timeout: timeout)
42
+ .bind do |output|
43
+ Try ::JSON::ParserError do
44
+ ::JSON.parse output
45
+ end
46
+ end.to_either.or do |error|
47
+ Left "parsing Terraform client output as JSON failed\n#{error}"
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,42 @@
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/client"
18
+ require "kitchen/terraform/client/execute_command"
19
+
20
+ # Creates a Terraform execution plan.
21
+ #
22
+ # @see https://www.terraform.io/docs/commands/plan.html Terraform plan command
23
+ module ::Kitchen::Terraform::Client::Plan
24
+ # Invokes the function.
25
+ #
26
+ # @param cli [::String] the path of the Terraform CLI to use to execute the plan command.
27
+ # @param logger [#<<] a logger to receive the stdout and stderr of the plan command.
28
+ # @param options [::Hash] the options for the plan command.
29
+ # @param root_module [::String] the path of the root Terraform module.
30
+ # @param timeout [::Integer] the maximum execution time in seconds for the plan command.
31
+ # @return [::Dry::Monads::Either] the result of the function.
32
+ def self.call(cli:, logger:, options:, root_module:, timeout:)
33
+ ::Kitchen::Terraform::Client::ExecuteCommand.call cli: cli,
34
+ command: "plan",
35
+ logger: logger,
36
+ options: options.merge(
37
+ input: false
38
+ ),
39
+ target: root_module,
40
+ timeout: timeout
41
+ end
42
+ end