kitchen-terraform 4.0.5 → 4.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2c1a4aa48257c95ba2c104c02546843d43fc16f67c8f95b7c930da4867dbd4c
4
- data.tar.gz: 53b09b266f62d36e1f7695fa1851c39f186db01f384cf655bd0e4d26ed714115
3
+ metadata.gz: a48b699368e638e6b55874c18b1880c0e44d86f07bd04efacc00e62f3ec70fe3
4
+ data.tar.gz: 79bb729336e5fa7344e586c169d3b11e0d177ff66f5a31d9cdab2f3fe1b4e0b4
5
5
  SHA512:
6
- metadata.gz: 8787b576af2b5d0c5875ed8bb5938b562ac0e51757707d01c1405b6221745de57b00b601d93d304a71bd28c479c43ecdae9c0ff8f9060bd206e1963804388d14
7
- data.tar.gz: 663ec394575f7c7bc6046f1df57b1400a417a3c5df5eeae28db84afb771e9887d67e5458c1460b8bf844eca9865bead513ab7347284ef679542724d4687889c4
6
+ metadata.gz: 3c141bf3e1608c70eca5a0b3c9b2ef7970f3eadca210eb8f4b07e13a85556d2ec35de82cc1fdb20eada1e62eca7bb5cc8c15d49697a648279891d571b1fc3a47
7
+ data.tar.gz: 2340ce65d820b817a5c63ace5d60825d802a3ff9e7af646bbca6e484022015f439e16d22583e7603160130bd9d3d8b177d387c286a4ff884d8da6df4e3a6428b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -212,24 +212,15 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
212
212
  include ::Kitchen::Terraform::Configurable
213
213
 
214
214
  # Applies changes to the state by selecting the test workspace, updating the dependency modules, validating the root
215
- # module, applying the state changes, and retrieving the state output.
215
+ # module, and applying the state changes.
216
216
  #
217
217
  # @raise [::Kitchen::Terraform::Error] if one of the steps fails.
218
218
  # @return [void]
219
- # @yieldparam output [::String] the state output.
220
219
  def apply(&block)
221
220
  run_workspace_select_instance
222
221
  apply_run_get
223
222
  apply_run_validate
224
223
  apply_run_apply
225
- ::Kitchen::Terraform::Command::Output.run(
226
- options: {
227
- cwd: config_root_module_directory,
228
- live_stream: logger,
229
- timeout: config_command_timeout,
230
- },
231
- &block
232
- )
233
224
  end
234
225
 
235
226
  # Creates a Test Kitchen instance by initializing the working directory and creating a test workspace.
@@ -266,6 +257,19 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
266
257
  )
267
258
  end
268
259
 
260
+ # Retrieves the Terraform state outputs.
261
+ #
262
+ # @raise [::Kitchen::Terraform::Error] if the retrieval fails.
263
+ # @return [void]
264
+ # @yieldparam output [::String] the state output.
265
+ def retrieve_outputs(&block)
266
+ ::Kitchen::Terraform::Command::Output.run(
267
+ options: {
268
+ cwd: config_root_module_directory, live_stream: logger, timeout: config_command_timeout,
269
+ }, &block
270
+ )
271
+ end
272
+
269
273
  # Verifies that the Terraform version available to the driver is supported.
270
274
  #
271
275
  # @raise [::Kitchen::UserError] if the version is not supported.
@@ -66,10 +66,6 @@ end
66
66
  # [-var-file=<variable_files.first>...] \
67
67
  # <directory>
68
68
  #
69
- # ===== Retrieving the Terraform Output
70
- #
71
- # terraform output -json
72
- #
73
69
  # === Configuration Attributes
74
70
  #
75
71
  # The provisioner has no configuration attributes, but the +provisioner+ mapping must be declared with the plugin name
@@ -90,18 +86,10 @@ class ::Kitchen::Provisioner::Terraform < ::Kitchen::Provisioner::Base
90
86
 
91
87
  # Converges a Test Kitchen instance.
92
88
  #
93
- # @param state [::Hash] the mutable instance and provisioner state.
89
+ # @param _state [::Hash] the mutable instance and provisioner state.
94
90
  # @raise [::Kitchen::ActionFailed] if the result of the action is a failure.
95
- def call(state)
96
- instance
97
- .driver
98
- .apply do |output:|
99
- state
100
- .store(
101
- :kitchen_terraform_outputs,
102
- output
103
- )
104
- end
91
+ def call(_state)
92
+ instance.driver.apply
105
93
  rescue ::Kitchen::Terraform::Error => error
106
94
  raise(
107
95
  ::Kitchen::ActionFailed,
@@ -15,6 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "json"
18
+ require "kitchen"
18
19
  require "kitchen/terraform/command"
19
20
  require "kitchen/terraform/error"
20
21
  require "kitchen/terraform/shell_out"
@@ -57,7 +58,7 @@ module ::Kitchen::Terraform::Command::Output
57
58
  # @api private
58
59
  def handle_kitchen_terraform(error:)
59
60
  /no\\ outputs\\ defined/.match ::Regexp.escape error.to_s or raise error
60
- yield output: {}
61
+ yield outputs: {}
61
62
  end
62
63
 
63
64
  # @api private
@@ -67,7 +68,7 @@ module ::Kitchen::Terraform::Command::Output
67
68
  command: "output -json",
68
69
  options: options,
69
70
  ) do |standard_output:|
70
- yield output: ::JSON.parse(standard_output)
71
+ yield outputs: ::JSON.parse(standard_output)
71
72
  end
72
73
  end
73
74
  end
@@ -72,7 +72,7 @@ module ::Kitchen::Terraform::Version
72
72
 
73
73
  # @api private
74
74
  def value
75
- self.value = ::Gem::Version.new "4.0.5" if not @value
75
+ self.value = ::Gem::Version.new "4.0.6" if not @value
76
76
  @value
77
77
  end
78
78
 
@@ -37,8 +37,13 @@ module Kitchen
37
37
  #
38
38
  # ==== kitchen verify
39
39
  #
40
- # A Test Kitchen instance is verified by iterating through the systems and executing the associated InSpec controls
41
- # against the hosts of each system.
40
+ # A Kitchen instance is verified by iterating through the systems and executing the associated InSpec controls
41
+ # against the hosts of each system. The outputs of the Terraform state are retrieved and exposed as attributes to
42
+ # the InSpec controls.
43
+ #
44
+ # ===== Retrieving the Terraform Output
45
+ #
46
+ # terraform output -json
42
47
  #
43
48
  # === Configuration Attributes
44
49
  #
@@ -74,11 +79,11 @@ module Kitchen
74
79
  #
75
80
  # @example
76
81
  # `kitchen verify suite-name`
77
- # @param kitchen_state [::Hash] the mutable instance and verifier state.
82
+ # @param _kitchen_state [::Hash] the mutable instance and verifier state.
78
83
  # @raise [::Kitchen::ActionFailed] if the result of the action is a failure.
79
84
  # @return [void]
80
- def call(kitchen_state)
81
- load_outputs kitchen_state: kitchen_state
85
+ def call(_kitchen_state)
86
+ load_outputs
82
87
  config_systems.each do |system|
83
88
  verify system: system
84
89
  end
@@ -127,12 +132,10 @@ module Kitchen
127
132
  )
128
133
  end
129
134
 
130
- def load_outputs(kitchen_state:)
131
- @outputs = ::Kitchen::Util.stringified_hash Hash kitchen_state.fetch :kitchen_terraform_outputs
132
- rescue ::KeyError => key_error
133
- raise ::Kitchen::Terraform::Error,
134
- "Loading Terraform outputs from the Kitchen state failed; this implies that the " \
135
- "Kitchen-Terraform provisioner has not successfully converged\n#{key_error}"
135
+ def load_outputs
136
+ instance.driver.retrieve_outputs do |outputs:|
137
+ @outputs.replace ::Kitchen::Util.stringified_hash outputs
138
+ end
136
139
  end
137
140
 
138
141
  def initialize(configuration = {})
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: 4.0.5
4
+ version: 4.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lane
@@ -57,7 +57,7 @@ cert_chain:
57
57
  BVaY4PA1920fVWRcwrNEzxNhWvlAlNCU9d63OhVIo1rD46E5/+fuWunp4ZyEJHIX
58
58
  lema55cN
59
59
  -----END CERTIFICATE-----
60
- date: 2018-12-02 00:00:00.000000000 Z
60
+ date: 2018-12-03 00:00:00.000000000 Z
61
61
  dependencies:
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bundler
metadata.gz.sig CHANGED
Binary file