kitchen-terraform 4.6.0 → 4.7.0

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: 2e916889997cb402f0784bca7fd292359454ccebd072cf4a83d2859f54c689c7
4
- data.tar.gz: 40837369dda96179987ea46fb225dc72f857ed4a47cee224f60eaa52f1bcb3f1
3
+ metadata.gz: '0848f7074fecffac74e56a1b39e4598dfd594d82e3bed471f0b1a63e169e9ff5'
4
+ data.tar.gz: a41ea06cd4949a662e4ca66b859afa44d2730653b59ff62b4d6dee3fc37c8d22
5
5
  SHA512:
6
- metadata.gz: 6f3a09a6ed6392d19f8a78502a3dc1a16db82eebeae3b4e2f30e527cbebdbc4b50acc1e5b542b876620c02653d034548d20dad0e6e3568a3bf73785721cffbb5
7
- data.tar.gz: d9ee18045c6070dd4b500e7c8208af3adc8662ecb756bcafdfe32279c49a0598d471caf7909f99c751e71b68f18307bd1dc0246f1f164553d02bef03fb896aee
6
+ metadata.gz: af6738cff28a4109dd94722f81e162cebe0723388a038f7db1fd96f5776b082145898748bae44e3794e14627e842f282a460dffc762cb693be1ee92400f8ef49
7
+ data.tar.gz: 52a8f5091ea9203bf8a3c44ca1af5d7ee3190395283ad94e096c2486c0bc84ebca5cd39d4abc15090af9a840e577c1254b79284100f8cecf6cbb343907fd2503
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -7,8 +7,9 @@
7
7
  [![Gem downloads total][gem-downloads-total-shield]][kitchen-terraform-gem]
8
8
 
9
9
  [![Build status][build-status-shield]][build-status]
10
- [![Test coverage][test-coverage-shield]][test-coverage]
10
+ [![Code coverage][code-coverage-shield]][code-coverage]
11
11
  [![Maintainability][maintainability-shield]][maintainability]
12
+ [![Technical debt][technical-debt-shield]][technical-debt]
12
13
  [![Dependencies][hakiri-shield]][hakiri]
13
14
 
14
15
  [![Gitter chat][gitter-shield]][gitter]
@@ -355,12 +356,14 @@ Kitchen-Terraform is distributed under the [Apache License][license].
355
356
 
356
357
  <!-- Markdown links and image definitions -->
357
358
 
358
- [build-status-shield]: https://img.shields.io/travis/newcontext-oss/kitchen-terraform.svg
359
+ [build-status-shield]: https://img.shields.io/travis/com/newcontext-oss/kitchen-terraform.svg
359
360
  [build-status]: https://travis-ci.com/newcontext-oss/kitchen-terraform
360
361
  [bundler-getting-started]: https://bundler.io/#getting-started
361
362
  [bundler-in-depth]: https://bundler.io/gemfile.html
362
363
  [bundler]: https://bundler.io/index.html#getting-started
363
364
  [changelog]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/CHANGELOG.md
365
+ [code-coverage-shield]: https://img.shields.io/codeclimate/coverage/newcontext-oss/kitchen-terraform.svg
366
+ [code-coverage]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/
364
367
  [contributing-document]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/CONTRIBUTING.md
365
368
  [docker]: https://www.docker.com/
366
369
  [docker-community-edition]: https://store.docker.com/editions/community/docker-ce-server-ubuntu
@@ -377,8 +380,8 @@ Kitchen-Terraform is distributed under the [Apache License][license].
377
380
  [kitchen-terraform-logo]: https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/logo.png
378
381
  [kitchen-terraform-tutorials]: https://newcontext-oss.github.io/kitchen-terraform/tutorials/
379
382
  [license]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/LICENSE
380
- [maintainability-shield]: https://api.codeclimate.com/v1/badges/73d4a2280a30e680bac4/maintainability
381
- [maintainability]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/maintainability
383
+ [maintainability-shield]: https://img.shields.io/codeclimate/maintainability-percentage/newcontext-oss/kitchen-terraform.svg
384
+ [maintainability]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/
382
385
  [new-context-github]: https://github.com/newcontext
383
386
  [new-context-linkedin]: https://www.linkedin.com/company/-new-context-
384
387
  [new-context-twitter]: https://twitter.com/newcontext
@@ -390,14 +393,14 @@ Kitchen-Terraform is distributed under the [Apache License][license].
390
393
  [ruby-installation]: https://www.ruby-lang.org/en/documentation/installation/
391
394
  [ruby]: https://www.ruby-lang.org/en/
392
395
  [rubygems-installing-gems]: http://guides.rubygems.org/rubygems-basics/#rubygems-installing-gems
396
+ [technical-debt-shield]: https://img.shields.io/codeclimate/tech-debt/newcontext-oss/kitchen-terraform.svg
397
+ [technical-debt]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/
393
398
  [terraform-cli]: https://www.terraform.io/docs/commands/index.html
394
399
  [terraform-driver]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Driver/Terraform
395
400
  [terraform-install]: https://www.terraform.io/intro/getting-started/install.html
396
401
  [terraform-provisioner]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Provisioner/Terraform
397
402
  [terraform-verifier]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Verifier/Terraform
398
403
  [terraform]: https://www.terraform.io/
399
- [test-coverage-shield]: https://api.codeclimate.com/v1/badges/73d4a2280a30e680bac4/test_coverage
400
- [test-coverage]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/test_coverage
401
404
  [test-kitchen-configuration-file]: https://docs.chef.io/config_yml_kitchen.html
402
405
  [test-kitchen]: http://kitchen.ci/index.html
403
406
  [tfenv]: https://github.com/kamatama41/tfenv
@@ -24,14 +24,15 @@ module Kitchen
24
24
  # against a system in the Terraform state.
25
25
  #
26
26
  # All systems within the same {https://kitchen.ci/docs/getting-started/adding-suite Kitchen suite} are tested
27
- # using the same {https://www.inspec.io/docs/reference/profiles/ InSpec profile}. The profile must be implemented
28
- # in the directory located at `<Kitchen root>/test/integration/<suite name>`.
27
+ # using the same {https://www.inspec.io/docs/reference/profiles/ InSpec profile} by default. The profile must be
28
+ # implemented in the directory located at `<Kitchen root>/test/integration/<suite name>`. This behaviour can be
29
+ # overridden with the <code>profile_locations</code> key.
29
30
  #
30
31
  # The values of all {https://www.terraform.io/docs/configuration/outputs.html Terraform outputs} are associated
31
32
  # with equivalently named
32
33
  # {https://www.inspec.io/docs/reference/profiles/#profile-attributes InSpec profile attributes}.
33
34
  #
34
- # The keys of a system mapping correlate to the options of the
35
+ # The keys of a system mapping correlate to the arguments and the options of the
35
36
  # {https://www.inspec.io/docs/reference/cli/#exec +inspec exec+} command-line interface subcomamand.
36
37
  #
37
38
  # ===== Required Keys
@@ -66,7 +67,7 @@ module Kitchen
66
67
  # ===== Optional Keys
67
68
  #
68
69
  # The following keys may be included by any system to alter the behaviour of InSpec. Any key which is omitted
69
- # will be associated with a default value as defined by InSpec.
70
+ # will be associated with a default value as defined by InSpec except where otherwise noted.
70
71
  #
71
72
  # ====== attrs
72
73
  #
@@ -297,6 +298,27 @@ module Kitchen
297
298
  # backend: ssh
298
299
  # port: 1234
299
300
  #
301
+ # ====== profile_locations
302
+ #
303
+ # The value of the <code>profile_locations</code> key is a sequence of scalars which is used to locate
304
+ # {https://www.inspec.io/docs/reference/profiles/ InSpec profiles} containing the controls to be executed against
305
+ # the system. This key corresponds to the LOCATIONS argument of <code>inspec exec</code>.
306
+ #
307
+ # The default value contains a single scalar which assumes that a profile exists locally for the associated
308
+ # {https://kitchen.ci/docs/getting-started/adding-suite Kitchen suite} at
309
+ # <code><KITCHEN ROOT>/test/integration/<KITCHEN SUITE NAME></code>.
310
+ #
311
+ # <em>Example kitchen.yml</em>
312
+ # verifier:
313
+ # name: terraform
314
+ # systems:
315
+ # - name: a system
316
+ # backend: local
317
+ # profile_locations:
318
+ # - supermarket://username/linux-baseline
319
+ # - /path/to/profile
320
+ # - /path/to/a_test.rb
321
+ #
300
322
  # ====== proxy_command
301
323
  #
302
324
  # The value of the +proxy_command+ key is a scalar which is used as a proxy command when connecting to a host via
@@ -535,6 +557,7 @@ module Kitchen
535
557
  optional(:password).filled :str?
536
558
  optional(:path).filled :str?
537
559
  optional(:port).value :int?
560
+ optional(:profile_locations).each :filled?, :str?
538
561
  optional(:proxy_command).filled :str?
539
562
  optional(:reporter).each(:filled?, :str?)
540
563
  optional(:self_signed).value :bool?
@@ -66,9 +66,11 @@ module Kitchen
66
66
 
67
67
  private
68
68
 
69
- def initialize(options:, profile_path:)
69
+ def initialize(options:, profile_locations:)
70
70
  @runner = ::Inspec::Runner.new options.merge logger: ::Inspec::Log.logger
71
- @runner.add_target path: profile_path
71
+ profile_locations.each do |profile_location|
72
+ @runner.add_target profile_location
73
+ end
72
74
  end
73
75
  end
74
76
  end
@@ -29,20 +29,21 @@ module Kitchen
29
29
  def exec(system:)
30
30
  system.each_host do |host:|
31
31
  ::Kitchen::Terraform::InSpec
32
- .new(options: options.merge(host: host), profile_path: profile_path)
33
- .info(message: "Verifying host #{host} of #{system}").exec
32
+ .new(options: options.merge(host: host), profile_locations: profile_locations)
33
+ .info(message: "#{system}: Verifying host #{host}").exec
34
34
  end
35
35
  end
36
36
 
37
37
  private
38
38
 
39
- attr_accessor :options, :profile_path
39
+ attr_accessor :options, :profile_locations
40
40
 
41
41
  # @param options [::Hash] options for execution.
42
- # @param profile_path [::String] the path to the InSpec profile which contains the controls to be executed.
43
- def initialize(options:, profile_path:)
42
+ # @param profile_locations [::Array<::String>] the locations of the InSpec profiles which contain the controls to
43
+ # be executed.
44
+ def initialize(options:, profile_locations:)
44
45
  self.options = options
45
- self.profile_path = profile_path
46
+ self.profile_locations = profile_locations
46
47
  end
47
48
  end
48
49
  end
@@ -26,18 +26,19 @@ module Kitchen
26
26
  # @return [void]
27
27
  def exec(system:)
28
28
  ::Kitchen::Terraform::InSpec
29
- .new(options: options, profile_path: profile_path).info(message: "Verifying #{system}").exec
29
+ .new(options: options, profile_locations: profile_locations).info(message: "#{system}: Verifying").exec
30
30
  end
31
31
 
32
32
  private
33
33
 
34
- attr_accessor :options, :profile_path
34
+ attr_accessor :options, :profile_locations
35
35
 
36
36
  # @param options [::Hash] options for execution.
37
- # @param profile_path [::String] the path to the InSpec profile which contains the controls to be executed.
38
- def initialize(options:, profile_path:)
37
+ # @param profile_locations [::Array<::String>] the locations of the InSpec profiles which contain the controls to
38
+ # be executed.
39
+ def initialize(options:, profile_locations:)
39
40
  self.options = options
40
- self.profile_path = profile_path
41
+ self.profile_locations = profile_locations
41
42
  end
42
43
  end
43
44
  end
@@ -66,11 +66,10 @@ module Kitchen
66
66
  # #verify verifies the system by executing InSpec.
67
67
  #
68
68
  # @param inspec_options [::Hash] the options to be passed to InSpec.
69
- # @param inspec_profile_path [::String] the path to the profile which InSpec will execute.
70
69
  # @return [self]
71
- def verify(inspec_options:, inspec_profile_path:, outputs:)
70
+ def verify(inspec_options:, outputs:)
72
71
  resolve outputs: outputs
73
- execute_inspec options: inspec_options, profile_path: inspec_profile_path
72
+ execute_inspec options: inspec_options
74
73
 
75
74
  self
76
75
  rescue => error
@@ -79,10 +78,11 @@ module Kitchen
79
78
 
80
79
  private
81
80
 
82
- def execute_inspec(options:, profile_path:)
83
- inspec.new(options: options_with_attributes(options: options), profile_path: profile_path).exec(
84
- system: self
85
- )
81
+ def execute_inspec(options:)
82
+ inspec.new(
83
+ options: options_with_attributes(options: options),
84
+ profile_locations: @mapping.fetch(:profile_locations)
85
+ ).exec(system: self)
86
86
  end
87
87
 
88
88
  def initialize(mapping:)
@@ -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.6.0" if not @value
75
+ self.value = ::Gem::Version.new "4.7.0" if not @value
76
76
  @value
77
77
  end
78
78
 
@@ -122,6 +122,7 @@ module Kitchen
122
122
  if config_fail_fast
123
123
  raise ::Kitchen::Terraform::Error, message
124
124
  else
125
+ logger.error message
125
126
  @error_messages.push message
126
127
  end
127
128
  end
@@ -139,9 +140,6 @@ module Kitchen
139
140
  @outputs = {}
140
141
  end
141
142
 
142
- def inspec_profile_path
143
- @inspec_profile_path ||= ::File.join config.fetch(:test_base_path), instance.suite.name
144
- end
145
143
 
146
144
  # load_needed_dependencies! loads the InSpec libraries required to verify a Terraform state.
147
145
  #
@@ -160,11 +158,9 @@ module Kitchen
160
158
  end
161
159
 
162
160
  def verify(system:)
163
- ::Kitchen::Terraform::System.new(mapping: system).verify(
164
- inspec_options: system_inspec_options(system: system),
165
- inspec_profile_path: inspec_profile_path,
166
- outputs: @outputs
167
- )
161
+ ::Kitchen::Terraform::System.new(
162
+ mapping: {profile_locations: [::File.join(config.fetch(:test_base_path), instance.suite.name)]}.merge(system)
163
+ ).verify(inspec_options: system_inspec_options(system: system), outputs: @outputs)
168
164
  rescue => error
169
165
  handle_error message: error.message
170
166
  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.6.0
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lane
@@ -61,7 +61,7 @@ cert_chain:
61
61
  XAjP/LERlXAwM+NCUycJw7BZMn7L2wIdnq6Le1rL6VJS17CZt2heuRtsF+3g0egR
62
62
  x97GmUumeM67PGeVodlIV65tdXrdlqKlHcE=
63
63
  -----END CERTIFICATE-----
64
- date: 2019-04-11 00:00:00.000000000 Z
64
+ date: 2019-04-13 00:00:00.000000000 Z
65
65
  dependencies:
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: guard-bundler
metadata.gz.sig CHANGED
Binary file