kitchen-terraform 0.7.0 → 1.0.0

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 (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
@@ -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 'terraform/integer_coercer'
18
- require 'terraform/simple_config'
19
-
20
- module Terraform
21
- # Behaviour for the [:parallelism] config option
22
- module ParallelismConfig
23
- include ::Terraform::SimpleConfig
24
-
25
- def self.extended(configurable_class)
26
- configurable_class
27
- .configure_required attr: :parallelism,
28
- coercer_class: ::Terraform::IntegerCoercer,
29
- default_value: 10
30
- end
31
- end
32
- end
@@ -1,40 +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 'terraform/simple_coercer'
18
-
19
- module Terraform
20
- # A coercer for config values that must be pathnames
21
- class PathnameCoercer
22
- def coerce(attr:, value:)
23
- coercer.coerce attr: attr, value: value
24
- configurable[attr] =
25
- configurable[attr].expand_path configurable[:kitchen_root]
26
- end
27
-
28
- private
29
-
30
- attr_accessor :coercer, :configurable
31
-
32
- def initialize(configurable:)
33
- self.coercer =
34
- ::Terraform::SimpleCoercer.new configurable: configurable,
35
- expected: 'a pathname',
36
- method: method(:Pathname)
37
- self.configurable = configurable
38
- end
39
- end
40
- end
@@ -1,30 +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 'terraform/command'
18
- require 'terraform/prepare_output_file'
19
-
20
- module Terraform
21
- # A command to plan an execution
22
- class PlanCommand < ::Terraform::Command
23
- private
24
-
25
- def initialize(target: '')
26
- super
27
- preparations.push ::Terraform::PrepareOutputFile.new file: options.out
28
- end
29
- end
30
- end
@@ -1,34 +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 'kitchen'
18
-
19
- module Terraform
20
- # A preparation for a command with an input file
21
- class PrepareInputFile
22
- def execute
23
- file.open {}
24
- end
25
-
26
- private
27
-
28
- attr_accessor :file
29
-
30
- def initialize(file:)
31
- self.file = file
32
- end
33
- end
34
- end
@@ -1,36 +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 'fileutils'
18
-
19
- module Terraform
20
- # A preparation for a command with an output file
21
- class PrepareOutputFile
22
- def execute
23
- parent_directory.mkpath
24
- file.open('a') {}
25
- end
26
-
27
- private
28
-
29
- attr_accessor :file, :parent_directory
30
-
31
- def initialize(file:)
32
- self.file = file
33
- self.parent_directory = file.parent
34
- end
35
- end
36
- end
@@ -1,59 +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 'kitchen'
18
- require 'mixlib/shellout'
19
-
20
- module Terraform
21
- # Facilitates execution of commands in a shell
22
- class ShellOut
23
- def execute(&block)
24
- block ||= proc {}
25
-
26
- command.prepare
27
- run_command
28
- block.call shell_out.stdout
29
- end
30
-
31
- private
32
-
33
- attr_accessor :command, :shell_out
34
-
35
- def initialize(
36
- cli:, command:, logger:, timeout: ::Mixlib::ShellOut::DEFAULT_READ_TIMEOUT
37
- )
38
- self.command = command
39
- self.shell_out = ::Mixlib::ShellOut.new "#{cli} #{command}",
40
- live_stream: logger,
41
- timeout: timeout
42
- end
43
-
44
- def instance_failures
45
- [
46
- ::Errno::EACCES, ::Errno::ENOENT, ::Mixlib::ShellOut::CommandTimeout,
47
- ::Mixlib::ShellOut::ShellCommandFailed
48
- ]
49
- end
50
-
51
- def run_command
52
- shell_out.run_command
53
- shell_out.error!
54
- rescue *instance_failures => error
55
- raise ::Kitchen::StandardError,
56
- %(`#{shell_out.command}` failed: "#{error.message}")
57
- end
58
- end
59
- end
@@ -1,30 +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 'terraform/command'
18
- require 'terraform/prepare_input_file'
19
-
20
- module Terraform
21
- # A command to show a state
22
- class ShowCommand < ::Terraform::Command
23
- private
24
-
25
- def initialize(target: '')
26
- super
27
- preparations.push ::Terraform::PrepareInputFile.new file: target
28
- end
29
- end
30
- end
@@ -1,36 +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
- module Terraform
18
- # Performs simple coercions
19
- class SimpleCoercer
20
- def coerce(attr:, value:)
21
- configurable[attr] = method.call value
22
- rescue ArgumentError, TypeError
23
- configurable.config_error attr: attr, expected: expected
24
- end
25
-
26
- private
27
-
28
- attr_accessor :configurable, :expected, :method
29
-
30
- def initialize(configurable:, expected:, method:)
31
- self.configurable = configurable
32
- self.expected = expected
33
- self.method = method
34
- end
35
- end
36
- end
@@ -1,28 +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
- module Terraform
18
- # Behaviour for simple config options
19
- module SimpleConfig
20
- def configure_required(attr:, coercer_class:, default_value:)
21
- required_config attr do |_, value, configurable|
22
- coercer_class
23
- .new(configurable: configurable).coerce attr: attr, value: value
24
- end
25
- default_config attr, default_value
26
- end
27
- end
28
- end
@@ -1,26 +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 'delegate'
18
-
19
- module Terraform
20
- # An unsupported version of Terraform
21
- class UnsupportedVersion < ::SimpleDelegator
22
- def if_not_supported
23
- yield
24
- end
25
- end
26
- end
@@ -1,23 +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 'terraform/command'
18
-
19
- module Terraform
20
- # A command to valdidate configuration files
21
- class ValidateCommand < ::Terraform::Command
22
- end
23
- end
@@ -1,40 +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 'terraform/pathname_coercer'
18
-
19
- module Terraform
20
- # A coercer for the [:variable_files] config option
21
- class VariableFilesCoercer
22
- def coerce(attr:, value:)
23
- configurable[attr] = Array(value).map do |pathname|
24
- coercer.coerce attr: attr, value: pathname
25
-
26
- configurable[attr]
27
- end
28
- end
29
-
30
- private
31
-
32
- attr_accessor :coercer, :configurable
33
-
34
- def initialize(configurable:)
35
- self.coercer =
36
- ::Terraform::PathnameCoercer.new configurable: configurable
37
- self.configurable = configurable
38
- end
39
- end
40
- end
@@ -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_relative 'simple_config'
18
- require_relative 'variable_files_coercer'
19
-
20
- module Terraform
21
- # Behaviour for the [:variable_files] config option
22
- module VariableFilesConfig
23
- include ::Terraform::SimpleConfig
24
-
25
- def self.extended(configurable_class)
26
- configurable_class
27
- .configure_required attr: :variable_files,
28
- coercer_class: ::Terraform::VariableFilesCoercer,
29
- default_value: []
30
- end
31
- end
32
- end