kitchen-inspec 2.0.0 → 2.4.1

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: cf548caf32e38ac4f651467f17d41b1057122cf6fd486964ba25021957c392f0
4
- data.tar.gz: ad173dfa6c01162998533c3630382c90b66ca0bf9fade4e85f234143af6574e0
3
+ metadata.gz: 70b9d58f03c7423e22abdc9aca993b2c7cb018a7ae31b7bca567ea95df03eddc
4
+ data.tar.gz: 8eda963ba46ed0861aca99a709ffd8d156c4aad2ff850a05ea1c5ac674dc6af0
5
5
  SHA512:
6
- metadata.gz: 160d7363ad42ef3f6f80796ffef20e72159cfe4ea462b3305b11496508258db0aeb33ecd98abdb441c06f6587d7ea300e81ed664b395ada665b3329d168c237f
7
- data.tar.gz: 6bc8274fab1fdd47df48d964d1b4b9aa135ea6ccb5e627cfc423b6899fa288aba7913e779931a5668de230aad4b9f9993b6556b891f4e70d2b8bbfe64c9b8388
6
+ metadata.gz: b814b4e844792e3b3b2180106246d52955fdf0d0ac97f3765708bee3ae83e34e0abea6c07be4919b44d29fc8c242e8e01c35ee15719604b933622153f6eac0dd
7
+ data.tar.gz: 4c48353297d378f7a376d416af1eca0d96c286349fe761536cd703d82a975fd3aef16e434c8d65299f3abdaeb8155ade43a37711c9dd2a2dde036d68c5db5d30
@@ -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
+ load_plugins # Must load plugins prior to config validation
90
+ inspec_config = ::Inspec::Config.new(opts)
82
91
 
83
- # initialize runner
84
- runner = ::Inspec::Runner.new(opts)
92
+ # handle 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 = "2.0.0".freeze
23
+ INSPEC_VERSION = "2.4.1".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: 2.0.0
4
+ version: 2.4.1
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-06-05 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inspec
@@ -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