kitchen-inspec 1.3.2 → 2.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6ca324c7d81de8fce56511eb61fa01de1aa140679b1bad5d0c8df02f86bb36d
4
- data.tar.gz: 2b0ea00f5221a1eeae360ddf01f4294cf4d16e8cc2b39cf4fff759cfdb046bd6
3
+ metadata.gz: 15ac2589b7e3344cae72f65dbe077de9dd2ae2f3fc57909237d08dfa621a5b1f
4
+ data.tar.gz: afb0e9233902dc0d008fc5019f829cd94eab297d30b2ad74be65db35ec68bca6
5
5
  SHA512:
6
- metadata.gz: ed7859aebb13637f361a783dc76ec5a8a11b791f2beaa7e6d11e9b6a2eb5fb0f57e264d9a3b0784f781958bb2b350e3099f3234cdc6b9d8b3443da2459ceaba2
7
- data.tar.gz: d9ac8df8f88b5f73868bd5ac1ac427c26b656365fbe66ead77c173f1b4b4f32483fd1599904fb8a42bd7283b2586444056c6f987e450ba0ee8307949d1451498
6
+ metadata.gz: e9f0b64ce565600a4ca279cad1abfebd06c9b505ae3d8afda29ca91996f55664a354937a4fdaec4f904643abcc137be709f78136afb908a55f4070d547ca00d4
7
+ data.tar.gz: 2249386355d430820a0e8f5aab4112cb3c6bc117d5a638566e414581aae5ce37fb4abede8bc21e23e5b3acda6e7bd62cfb251b256241647b3f25f993bd5c3b37
@@ -37,8 +37,15 @@ module Kitchen
37
37
  kitchen_verifier_api_version 1
38
38
  plugin_version Kitchen::Verifier::INSPEC_VERSION
39
39
 
40
+ # Chef InSpec is based on RSpec, which is not thread safe
41
+ # (https://github.com/rspec/rspec-core/issues/1254)
42
+ # Tell test kitchen not to multithread the verify step
43
+ no_parallel_for :verify
44
+
40
45
  default_config :inspec_tests, []
41
- default_config :load_plugins, false
46
+ default_config :load_plugins, true
47
+ default_config :plugin_config, {}
48
+ default_config :backend_cache, true
42
49
 
43
50
  # A lifecycle method that should be invoked when the object is about
44
51
  # ready to be used. A reference to an Instance is required as
@@ -76,25 +83,23 @@ module Kitchen
76
83
  # add inputs
77
84
  setup_inputs(opts, config)
78
85
 
79
- # setup logger
86
+ # setup Inspec
80
87
  ::Inspec::Log.init(STDERR)
81
88
  ::Inspec::Log.level = Kitchen::Util.from_logger_level(logger.level)
89
+ inspec_config = ::Inspec::Config.new(opts)
82
90
 
83
- # initialize runner
84
- runner = ::Inspec::Runner.new(opts)
91
+ # handle plugins
92
+ load_plugins
93
+ setup_plugin_config(inspec_config)
85
94
 
86
- # load plugins
87
- if config[:load_plugins]
88
- v2_loader = ::Inspec::Plugin::V2::Loader.new
89
- v2_loader.load_all
90
- v2_loader.exit_on_load_error
91
- end
95
+ # initialize runner
96
+ runner = ::Inspec::Runner.new(inspec_config)
92
97
 
93
98
  # add each profile to runner
94
99
  tests = collect_tests
95
100
  profile_ctx = nil
96
101
  tests.each do |target|
97
- profile_ctx = runner.add_target(target, opts)
102
+ profile_ctx = runner.add_target(target)
98
103
  end
99
104
 
100
105
  profile_ctx ||= []
@@ -136,6 +141,32 @@ module Kitchen
136
141
  end
137
142
  end
138
143
 
144
+ def load_plugins
145
+ return unless config[:load_plugins]
146
+
147
+ v2_loader = ::Inspec::Plugin::V2::Loader.new
148
+ v2_loader.load_all
149
+ v2_loader.exit_on_load_error
150
+
151
+ # Suppress input caching or all suites will get identical inputs, not different ones
152
+ if ::Inspec::InputRegistry.instance.respond_to?(:cache_inputs=) && config[:cache_inputs]
153
+ ::Inspec::InputRegistry.instance.cache_inputs = !!config[:cache_inputs]
154
+ end
155
+ end
156
+
157
+ def setup_plugin_config(inspec_config)
158
+ return unless config[:load_plugins]
159
+
160
+ unless inspec_config.respond_to?(:merge_plugin_config)
161
+ logger.warn("kitchen-inspec: skipping `plugin_config` which requires InSpec version 4.26.2 or higher. Your version: #{::Inspec::VERSION}")
162
+ return
163
+ end
164
+
165
+ config[:plugin_config].each do |plugin_name, plugin_config|
166
+ inspec_config.merge_plugin_config(plugin_name, plugin_config)
167
+ end
168
+ end
169
+
139
170
  # (see Base#load_needed_dependencies!)
140
171
  def load_needed_dependencies!
141
172
  require "inspec"
@@ -158,7 +189,7 @@ module Kitchen
158
189
  #
159
190
  # we support the base directories
160
191
  # - test/integration
161
- # - test/integration/inspec (prefered if used with other test environments)
192
+ # - test/integration/inspec (preferred if used with other test environments)
162
193
  #
163
194
  # we do not filter for specific directories, this is core of inspec
164
195
  #
@@ -291,7 +322,7 @@ module Kitchen
291
322
  # @api private
292
323
  def runner_options_for_winrm(config_data)
293
324
  kitchen = instance.transport.send(:connection_options, config_data).dup
294
- opts = {
325
+ {
295
326
  "backend" => "winrm",
296
327
  "logger" => logger,
297
328
  "ssl" => URI(kitchen[:endpoint]).scheme == "https",
@@ -304,7 +335,6 @@ module Kitchen
304
335
  "connection_retry_sleep" => kitchen[:connection_retry_sleep],
305
336
  "max_wait_until_ready" => kitchen[:max_wait_until_ready],
306
337
  }
307
- opts
308
338
  end
309
339
 
310
340
  # Returns a configuration Hash that can be passed to a `Inspec::Runner`.
@@ -335,11 +365,10 @@ module Kitchen
335
365
  # @return [Hash] a configuration hash of string-based keys
336
366
  # @api private
337
367
  def runner_options_for_exec(config_data)
338
- opts = {
368
+ {
339
369
  "backend" => "local",
340
370
  "logger" => logger,
341
371
  }
342
- opts
343
372
  end
344
373
 
345
374
  # Returns a configuration Hash that can be passed to a `Inspec::Runner`.
@@ -20,6 +20,6 @@
20
20
  module Kitchen
21
21
  module Verifier
22
22
  # Version string for InSpec Kitchen verifier
23
- INSPEC_VERSION = "1.3.2".freeze
23
+ INSPEC_VERSION = "2.4.0".freeze
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-inspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-15 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inspec
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.47'
19
+ version: 2.2.64
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.47'
29
+ version: 2.2.64
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5.0'
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '1.6'
39
+ version: '2.7'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '3'
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '1.6'
49
+ version: '2.7'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '3'
@@ -54,16 +54,22 @@ dependencies:
54
54
  name: hashie
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '3.4'
60
+ - - "<="
61
+ - !ruby/object:Gem::Version
62
+ version: '5.0'
60
63
  type: :runtime
61
64
  prerelease: false
62
65
  version_requirements: !ruby/object:Gem::Requirement
63
66
  requirements:
64
- - - "~>"
67
+ - - ">="
65
68
  - !ruby/object:Gem::Version
66
69
  version: '3.4'
70
+ - - "<="
71
+ - !ruby/object:Gem::Version
72
+ version: '5.0'
67
73
  description: A Test Kitchen Verifier for InSpec
68
74
  email:
69
75
  - info@chef.io
@@ -93,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
99
  - !ruby/object:Gem::Version
94
100
  version: '0'
95
101
  requirements: []
96
- rubygems_version: 3.0.3
102
+ rubygems_version: 3.1.4
97
103
  signing_key:
98
104
  specification_version: 4
99
105
  summary: A Test Kitchen Verifier for InSpec