kitchen-terraform 4.0.3 → 4.0.4

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: aef9e77a8ac8243cd10180f14702d8c496bdc343a9d781819ec6beca036f6e05
4
- data.tar.gz: c09c903e660799f72db02456358c0fd4447dbe846901d54b234de2b4324eabb8
3
+ metadata.gz: e2c1885da5297ea917cc40b1051430ce2cb273d155b6ada091e6f9cf7a6efadf
4
+ data.tar.gz: fd52cc7bd0d9a572ff4c9d329759508b101255be6bc4ab6ebf1a6ad27d7ffc7d
5
5
  SHA512:
6
- metadata.gz: 0f6672ac40da3df640e4971962c47f9604d91502d0f07e8b5f075c753def38c3607e5480919aebb74165c149b52410daff6c0c651c2db2e8c92ded5d95a5eddf
7
- data.tar.gz: e998e5fa5997e6198244df8e350cd40c420202269dbc118863e781417efe91a9175350de6785fefe71901b6c202b6ebcd13a1ca36151adae420e6d3c1832417d
6
+ metadata.gz: fc75638d21b316bd4cc2b50af1e3f859e9f2e2c9ec37199004b5b5cb0cd431444eb0f4c43b6e16ad933a1fd435ce759422c83b4ec42fdfa8c91f09120efca68a
7
+ data.tar.gz: 7e80c7ccc2fc267fa926171943e330dfad0b6e4919b58e58a463b2cbc27a84c2e1b6a0edbcbe5eac713854a994204ab8b76780bba4c8e37551e14aa0faf55b93
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -222,16 +222,14 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
222
222
  apply_run_get
223
223
  apply_run_validate
224
224
  apply_run_apply
225
- ::Kitchen::Terraform::Command::Output
226
- .run(
227
- options:
228
- {
229
- cwd: config_root_module_directory,
230
- live_stream: logger,
231
- timeout: config_command_timeout
232
- },
233
- &block
234
- )
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
+ )
235
233
  end
236
234
 
237
235
  # Creates a Test Kitchen instance by initializing the working directory and creating a test workspace.
@@ -273,97 +271,76 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
273
271
  # @raise [::Kitchen::UserError] if the version is not supported.
274
272
  # @return [void]
275
273
  def verify_dependencies
276
- logger
277
- .warn(
278
- ::Kitchen::Terraform::ClientVersionVerifier
279
- .new
280
- .verify(
281
- version_output:
282
- ::Kitchen::Terraform::ShellOut
283
- .run(
284
- command: "version",
285
- options:
286
- {
287
- cwd: ::Dir.pwd,
288
- live_stream: logger,
289
- timeout: 600
290
- }
291
- )
292
- )
293
- )
294
- rescue ::Kitchen::Terraform::Error => error
295
- raise(
296
- ::Kitchen::UserError,
297
- error.message
274
+ logger.warn ::Kitchen::Terraform::ClientVersionVerifier.new.verify(
275
+ version_output: ::Kitchen::Terraform::ShellOut.run(
276
+ command: "version",
277
+ options: {
278
+ cwd: ::Dir.pwd,
279
+ live_stream: logger,
280
+ timeout: 600,
281
+ },
282
+ ),
298
283
  )
284
+ rescue ::Kitchen::Terraform::Error => error
285
+ raise ::Kitchen::UserError, error.message
299
286
  end
300
287
 
301
288
  private
302
289
 
303
290
  # @api private
304
291
  def apply_run_apply
305
- ::Kitchen::Terraform::ShellOut
306
- .run(
307
- command:
308
- "apply " \
309
- "#{lock_flag} " \
310
- "#{lock_timeout_flag} " \
311
- "-input=false " \
312
- "-auto-approve=true " \
313
- "#{color_flag} " \
314
- "#{parallelism_flag} " \
315
- "-refresh=true " \
316
- "#{variables_flags} " \
317
- "#{variable_files_flags}",
318
- options:
319
- {
320
- cwd: config_root_module_directory,
321
- live_stream: logger,
322
- timeout: config_command_timeout
323
- }
324
- )
292
+ ::Kitchen::Terraform::ShellOut.run(
293
+ command: "apply " \
294
+ "#{lock_flag} " \
295
+ "#{lock_timeout_flag} " \
296
+ "-input=false " \
297
+ "-auto-approve=true " \
298
+ "#{color_flag} " \
299
+ "#{parallelism_flag} " \
300
+ "-refresh=true " \
301
+ "#{variables_flags} " \
302
+ "#{variable_files_flags}",
303
+ options: {
304
+ cwd: config_root_module_directory,
305
+ live_stream: logger,
306
+ timeout: config_command_timeout,
307
+ },
308
+ )
325
309
  end
326
310
 
327
311
  # @api private
328
312
  def apply_run_get
329
- ::Kitchen::Terraform::ShellOut
330
- .run(
331
- command: "get -update",
332
- options:
333
- {
334
- cwd: config_root_module_directory,
335
- live_stream: logger,
336
- timeout: config_command_timeout
337
- }
338
- )
313
+ ::Kitchen::Terraform::ShellOut.run(
314
+ command: "get -update",
315
+ options: {
316
+ cwd: config_root_module_directory,
317
+ live_stream: logger,
318
+ timeout: config_command_timeout,
319
+ },
320
+ )
339
321
  end
340
322
 
341
323
  # @api private
342
324
  def apply_run_validate
343
- ::Kitchen::Terraform::ShellOut
344
- .run(
345
- command:
346
- "validate " \
347
- "-check-variables=true " \
348
- "#{color_flag} " \
349
- "#{variables_flags} " \
350
- "#{variable_files_flags}",
351
- options:
352
- {
353
- cwd: config_root_module_directory,
354
- live_stream: logger,
355
- timeout: config_command_timeout
356
- }
357
- )
325
+ ::Kitchen::Terraform::ShellOut.run(
326
+ command: "validate " \
327
+ "-check-variables=true " \
328
+ "#{color_flag} " \
329
+ "#{variables_flags} " \
330
+ "#{variable_files_flags}",
331
+ options: {
332
+ cwd: config_root_module_directory,
333
+ live_stream: logger,
334
+ timeout: config_command_timeout,
335
+ },
336
+ )
358
337
  end
359
338
 
360
339
  # @api private
361
340
  def backend_configurations_flags
362
- config_backend_configurations
363
- .map do |key, value|
364
- "-backend-config=#{::Shellwords.escape "#{key}=#{value}"}"
365
- end
366
- .join " "
341
+ config_backend_configurations.map do |key, value|
342
+ "-backend-config=\"#{::Shellwords.escape key}=#{::Shellwords.escape value}\""
343
+ end.join " "
367
344
  end
368
345
 
369
346
  # api private
@@ -373,112 +350,94 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
373
350
 
374
351
  # @api private
375
352
  def create_run_init
376
- ::Kitchen::Terraform::ShellOut
377
- .run(
378
- command:
379
- "init " \
380
- "-input=false " \
381
- "#{lock_flag} " \
382
- "#{lock_timeout_flag} " \
383
- "#{color_flag} " \
384
- "-upgrade " \
385
- "-force-copy " \
386
- "-backend=true " \
387
- "#{backend_configurations_flags} " \
388
- "-get=true " \
389
- "-get-plugins=true " \
390
- "#{plugin_directory_flag} " \
391
- "-verify-plugins=true",
392
- options:
393
- {
394
- cwd: config_root_module_directory,
395
- live_stream: logger,
396
- timeout: config_command_timeout
397
- }
398
- )
353
+ ::Kitchen::Terraform::ShellOut.run(
354
+ command: "init " \
355
+ "-input=false " \
356
+ "#{lock_flag} " \
357
+ "#{lock_timeout_flag} " \
358
+ "#{color_flag} " \
359
+ "-upgrade " \
360
+ "-force-copy " \
361
+ "-backend=true " \
362
+ "#{backend_configurations_flags} " \
363
+ "-get=true " \
364
+ "-get-plugins=true " \
365
+ "#{plugin_directory_flag} " \
366
+ "-verify-plugins=true",
367
+ options: {
368
+ cwd: config_root_module_directory,
369
+ live_stream: logger,
370
+ timeout: config_command_timeout,
371
+ },
372
+ )
399
373
  end
400
374
 
401
375
  # @api private
402
376
  def destroy_run_destroy
403
- ::Kitchen::Terraform::ShellOut
404
- .run(
405
- command:
406
- "destroy " \
407
- "-auto-approve " \
408
- "#{lock_flag} " \
409
- "#{lock_timeout_flag} " \
410
- "-input=false " \
411
- "#{color_flag} " \
412
- "#{parallelism_flag} " \
413
- "-refresh=true " \
414
- "#{variables_flags} " \
415
- "#{variable_files_flags}",
416
- options:
417
- {
418
- cwd: config_root_module_directory,
419
- live_stream: logger,
420
- timeout: config_command_timeout
421
- }
422
- )
377
+ ::Kitchen::Terraform::ShellOut.run(
378
+ command: "destroy " \
379
+ "-auto-approve " \
380
+ "#{lock_flag} " \
381
+ "#{lock_timeout_flag} " \
382
+ "-input=false " \
383
+ "#{color_flag} " \
384
+ "#{parallelism_flag} " \
385
+ "-refresh=true " \
386
+ "#{variables_flags} " \
387
+ "#{variable_files_flags}",
388
+ options: {
389
+ cwd: config_root_module_directory,
390
+ live_stream: logger,
391
+ timeout: config_command_timeout,
392
+ },
393
+ )
423
394
  end
424
395
 
425
396
  # @api private
426
397
  def destroy_run_init
427
- ::Kitchen::Terraform::ShellOut
428
- .run(
429
- command:
430
- "init " \
431
- "-input=false " \
432
- "#{lock_flag} " \
433
- "#{lock_timeout_flag} " \
434
- "#{color_flag} " \
435
- "-force-copy " \
436
- "-backend=true " \
437
- "#{backend_configurations_flags} " \
438
- "-get=true " \
439
- "-get-plugins=true " \
440
- "#{plugin_directory_flag} " \
441
- "-verify-plugins=true",
442
- options:
443
- {
444
- cwd: config_root_module_directory,
445
- live_stream: logger,
446
- timeout: config_command_timeout
447
- }
448
- )
398
+ ::Kitchen::Terraform::ShellOut.run(
399
+ command: "init " \
400
+ "-input=false " \
401
+ "#{lock_flag} " \
402
+ "#{lock_timeout_flag} " \
403
+ "#{color_flag} " \
404
+ "-force-copy " \
405
+ "-backend=true " \
406
+ "#{backend_configurations_flags} " \
407
+ "-get=true " \
408
+ "-get-plugins=true " \
409
+ "#{plugin_directory_flag} " \
410
+ "-verify-plugins=true",
411
+ options: {
412
+ cwd: config_root_module_directory,
413
+ live_stream: logger,
414
+ timeout: config_command_timeout,
415
+ },
416
+ )
449
417
  end
450
418
 
451
419
  # @api private
452
420
  def destroy_run_workspace_delete_instance
453
- ::Kitchen::Terraform::ShellOut
454
- .run(
455
- command: "workspace delete kitchen-terraform-#{instance_name}",
456
- options:
457
- {
458
- cwd: config_root_module_directory,
459
- live_stream: logger,
460
- timeout: config_command_timeout
461
- }
462
- )
421
+ ::Kitchen::Terraform::ShellOut.run(
422
+ command: "workspace delete #{workspace_name}",
423
+ options: {
424
+ cwd: config_root_module_directory,
425
+ live_stream: logger,
426
+ timeout: config_command_timeout,
427
+ },
428
+ )
463
429
  end
464
430
 
465
431
  # @api private
466
432
  def destroy_run_workspace_select_default
467
- ::Kitchen::Terraform::ShellOut
468
- .run(
469
- command: "workspace select default",
470
- options:
471
- {
472
- cwd: config_root_module_directory,
473
- live_stream: logger,
474
- timeout: config_command_timeout
475
- }
476
- )
477
- end
478
-
479
- # @api private
480
- def instance_name
481
- @instance_name ||= instance.name
433
+ ::Kitchen::Terraform::ShellOut.run(
434
+ command: "workspace select default",
435
+ options: {
436
+ cwd: config_root_module_directory,
437
+ live_stream: logger,
438
+ timeout: config_command_timeout,
439
+ },
440
+ )
482
441
  end
483
442
 
484
443
  # @api private
@@ -498,9 +457,11 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
498
457
 
499
458
  # @api private
500
459
  def plugin_directory_flag
501
- config_plugin_directory and
502
- "-plugin-dir=#{::Shellwords.escape config_plugin_directory}" or
460
+ if config_plugin_directory
461
+ "-plugin-dir=\"#{::Shellwords.shelljoin ::Shellwords.shellsplit config_plugin_directory}\""
462
+ else
503
463
  ""
464
+ end
504
465
  end
505
466
 
506
467
  # @api private
@@ -510,44 +471,40 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
510
471
 
511
472
  # @api private
512
473
  def run_workspace_select_instance
513
- ::Kitchen::Terraform::ShellOut
514
- .run(
515
- command: "workspace select kitchen-terraform-#{instance_name}",
516
- options:
517
- {
518
- cwd: config_root_module_directory,
519
- live_stream: logger,
520
- timeout: config_command_timeout
521
- }
522
- )
474
+ ::Kitchen::Terraform::ShellOut.run(
475
+ command: "workspace select #{workspace_name}",
476
+ options: {
477
+ cwd: config_root_module_directory,
478
+ live_stream: logger,
479
+ timeout: config_command_timeout,
480
+ },
481
+ )
523
482
  rescue ::Kitchen::Terraform::Error
524
- ::Kitchen::Terraform::ShellOut
525
- .run(
526
- command: "workspace new kitchen-terraform-#{instance_name}",
527
- options:
528
- {
529
- cwd: config_root_module_directory,
530
- live_stream: logger,
531
- timeout: config_command_timeout
532
- }
533
- )
483
+ ::Kitchen::Terraform::ShellOut.run(
484
+ command: "workspace new #{workspace_name}",
485
+ options: {
486
+ cwd: config_root_module_directory,
487
+ live_stream: logger,
488
+ timeout: config_command_timeout,
489
+ },
490
+ )
534
491
  end
535
492
 
536
493
  # @api private
537
494
  def variable_files_flags
538
- config_variable_files
539
- .map do |path|
540
- "-var-file=#{::Shellwords.escape path}"
541
- end
542
- .join " "
495
+ config_variable_files.map do |path|
496
+ "-var-file=\"#{::Shellwords.shelljoin ::Shellwords.shellsplit path}\""
497
+ end.join " "
543
498
  end
544
499
 
545
500
  # @api private
546
501
  def variables_flags
547
- config_variables
548
- .map do |key, value|
549
- "-var=#{::Shellwords.escape "#{key}=#{value}"}"
550
- end
551
- .join " "
502
+ config_variables.map do |key, value|
503
+ "-var=\"#{::Shellwords.escape key}=#{::Shellwords.join ::Shellwords.split value}\""
504
+ end.join " "
505
+ end
506
+
507
+ def workspace_name
508
+ @workspace_name ||= "kitchen-terraform-#{::Shellwords.escape instance.name}"
552
509
  end
553
510
  end
@@ -27,6 +27,8 @@ class ::Kitchen::Terraform::InSpecOptionsMapper
27
27
  system_keys.&(options_keys).each do |key|
28
28
  options.store system_to_options.dig(key), system.fetch(key)
29
29
  end
30
+
31
+ options
30
32
  end
31
33
 
32
34
  private
@@ -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.3" if not @value
75
+ self.value = ::Gem::Version.new "4.0.4" if not @value
76
76
  @value
77
77
  end
78
78
 
@@ -127,10 +127,6 @@ module Kitchen
127
127
  )
128
128
  end
129
129
 
130
- def configure_inspec_system_options(system:)
131
- ::Kitchen::Terraform::InSpecOptionsMapper.new(system: system).map options: @inspec_options
132
- end
133
-
134
130
  def load_outputs(kitchen_state:)
135
131
  @outputs = ::Kitchen::Util.stringified_hash Hash kitchen_state.fetch :kitchen_terraform_outputs
136
132
  rescue ::KeyError => key_error
@@ -173,6 +169,10 @@ module Kitchen
173
169
  @system_hosts_resolver ||= ::Kitchen::Terraform::SystemHostsResolver.new outputs: @outputs
174
170
  end
175
171
 
172
+ def system_inspec_options(system:)
173
+ ::Kitchen::Terraform::InSpecOptionsMapper.new(system: system).map options: @inspec_options.dup
174
+ end
175
+
176
176
  def transport_connection_options
177
177
  ::Kitchen::Util.stringified_hash(
178
178
  instance.transport.diagnose.select do |key|
@@ -184,12 +184,11 @@ module Kitchen
184
184
  end
185
185
 
186
186
  def verify(system:)
187
- configure_inspec_system_options system: system
188
187
  ::Kitchen::Terraform::System
189
188
  .new(mapping: system)
190
189
  .resolve_attrs(system_attrs_resolver: system_attrs_resolver)
191
190
  .resolve_hosts(system_hosts_resolver: system_hosts_resolver)
192
- .verify(inspec_options: @inspec_options, inspec_profile_path: inspec_profile_path)
191
+ .verify(inspec_options: system_inspec_options(system: system), inspec_profile_path: inspec_profile_path)
193
192
  end
194
193
  end
195
194
  end
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.3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lane
@@ -57,8 +57,22 @@ cert_chain:
57
57
  BVaY4PA1920fVWRcwrNEzxNhWvlAlNCU9d63OhVIo1rD46E5/+fuWunp4ZyEJHIX
58
58
  lema55cN
59
59
  -----END CERTIFICATE-----
60
- date: 2018-10-05 00:00:00.000000000 Z
60
+ date: 2018-11-23 00:00:00.000000000 Z
61
61
  dependencies:
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.17'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.17'
62
76
  - !ruby/object:Gem::Dependency
63
77
  name: guard
64
78
  requirement: !ruby/object:Gem::Requirement
@@ -311,6 +325,20 @@ dependencies:
311
325
  - - "~>"
312
326
  - !ruby/object:Gem::Version
313
327
  version: '1.8'
328
+ - !ruby/object:Gem::Dependency
329
+ name: tty-which
330
+ requirement: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - "~>"
333
+ - !ruby/object:Gem::Version
334
+ version: 0.4.0
335
+ type: :development
336
+ prerelease: false
337
+ version_requirements: !ruby/object:Gem::Requirement
338
+ requirements:
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: 0.4.0
314
342
  - !ruby/object:Gem::Dependency
315
343
  name: yard
316
344
  requirement: !ruby/object:Gem::Requirement
@@ -505,7 +533,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
505
533
  requirements:
506
534
  - Terraform >= 0.11.4, < 0.12.0
507
535
  rubyforge_project:
508
- rubygems_version: 2.7.7
536
+ rubygems_version: 2.7.8
509
537
  signing_key:
510
538
  specification_version: 4
511
539
  summary: Test Kitchen plugins for testing Terraform configuration
metadata.gz.sig CHANGED
Binary file