kitchen-inspec 2.3.0 → 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: 3c1940625ae539de46cf0046bca2290acf91d138d7fbe2ee43f904c904676104
4
- data.tar.gz: b1a59f220fbc714609035888791a94935bdfd9b018fbf77a17704ad9262b2baf
3
+ metadata.gz: 15ac2589b7e3344cae72f65dbe077de9dd2ae2f3fc57909237d08dfa621a5b1f
4
+ data.tar.gz: afb0e9233902dc0d008fc5019f829cd94eab297d30b2ad74be65db35ec68bca6
5
5
  SHA512:
6
- metadata.gz: d6fa1b9cd9e0504709cd6a93dc86bba032c10459e8c3c45d983b40cc94cb9c69a79d7a54781465c6c46ba9b1eb888f25782d472e420f96e2d07f8821b12399aa
7
- data.tar.gz: 25cf73132b7f783e8debb944ab2dd4f95c779a966004a264aacfb2675a28f6d7778ed4973770be7d4c8ba04627141128b8d6b114d347b493a6ab58a572ec71a4
6
+ metadata.gz: e9f0b64ce565600a4ca279cad1abfebd06c9b505ae3d8afda29ca91996f55664a354937a4fdaec4f904643abcc137be709f78136afb908a55f4070d547ca00d4
7
+ data.tar.gz: 2249386355d430820a0e8f5aab4112cb3c6bc117d5a638566e414581aae5ce37fb4abede8bc21e23e5b3acda6e7bd62cfb251b256241647b3f25f993bd5c3b37
@@ -44,6 +44,7 @@ module Kitchen
44
44
 
45
45
  default_config :inspec_tests, []
46
46
  default_config :load_plugins, true
47
+ default_config :plugin_config, {}
47
48
  default_config :backend_cache, true
48
49
 
49
50
  # A lifecycle method that should be invoked when the object is about
@@ -82,23 +83,17 @@ module Kitchen
82
83
  # add inputs
83
84
  setup_inputs(opts, config)
84
85
 
85
- # setup logger
86
+ # setup Inspec
86
87
  ::Inspec::Log.init(STDERR)
87
88
  ::Inspec::Log.level = Kitchen::Util.from_logger_level(logger.level)
89
+ inspec_config = ::Inspec::Config.new(opts)
88
90
 
89
- # load plugins
90
- if config[:load_plugins]
91
- v2_loader = ::Inspec::Plugin::V2::Loader.new
92
- v2_loader.load_all
93
- v2_loader.exit_on_load_error
94
-
95
- if ::Inspec::InputRegistry.instance.respond_to?(:cache_inputs=) && config[:cache_inputs]
96
- ::Inspec::InputRegistry.instance.cache_inputs = !!config[:cache_inputs]
97
- end
98
- end
91
+ # handle plugins
92
+ load_plugins
93
+ setup_plugin_config(inspec_config)
99
94
 
100
95
  # initialize runner
101
- runner = ::Inspec::Runner.new(opts)
96
+ runner = ::Inspec::Runner.new(inspec_config)
102
97
 
103
98
  # add each profile to runner
104
99
  tests = collect_tests
@@ -146,6 +141,32 @@ module Kitchen
146
141
  end
147
142
  end
148
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
+
149
170
  # (see Base#load_needed_dependencies!)
150
171
  def load_needed_dependencies!
151
172
  require "inspec"
@@ -20,6 +20,6 @@
20
20
  module Kitchen
21
21
  module Verifier
22
22
  # Version string for InSpec Kitchen verifier
23
- INSPEC_VERSION = "2.3.0".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: 2.3.0
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: 2021-01-28 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