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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/kitchen/driver/terraform.rb +161 -204
- data/lib/kitchen/terraform/inspec_options_mapper.rb +2 -0
- data/lib/kitchen/terraform/version.rb +1 -1
- data/lib/kitchen/verifier/terraform.rb +5 -6
- metadata +31 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2c1885da5297ea917cc40b1051430ce2cb273d155b6ada091e6f9cf7a6efadf
|
4
|
+
data.tar.gz: fd52cc7bd0d9a572ff4c9d329759508b101255be6bc4ab6ebf1a6ad27d7ffc7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc75638d21b316bd4cc2b50af1e3f859e9f2e2c9ec37199004b5b5cb0cd431444eb0f4c43b6e16ad933a1fd435ce759422c83b4ec42fdfa8c91f09120efca68a
|
7
|
+
data.tar.gz: 7e80c7ccc2fc267fa926171943e330dfad0b6e4919b58e58a463b2cbc27a84c2e1b6a0edbcbe5eac713854a994204ab8b76780bba4c8e37551e14aa0faf55b93
|
checksums.yaml.gz.sig
CHANGED
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
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
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
|
-
.
|
278
|
-
|
279
|
-
|
280
|
-
.
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
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
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
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
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
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
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
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
|
-
.
|
364
|
-
|
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
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
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
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
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
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
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
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
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
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
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
|
502
|
-
"-plugin-dir
|
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
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
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
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
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
|
-
.
|
540
|
-
|
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
|
-
.
|
549
|
-
|
550
|
-
|
551
|
-
|
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
|
@@ -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:
|
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.
|
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-
|
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.
|
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
|