kitchen-inspec 2.2.2 → 2.5.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: 20386a2940c8e28bf2b427d307b2da9bf6f369c322caa16f18da73188c423a6e
4
- data.tar.gz: 07b179d4ba4f967ab4924a43a36f709362522db8aad584faa05fc9f493a06c79
3
+ metadata.gz: 8200c1bc26b6c3d93ad382da18a082f7a86845f7873edd5db635deead48a9416
4
+ data.tar.gz: 44a1cdb359735deb16b25a91854e2df9cfd150ebf6f9defbba92784ce8fbf0d5
5
5
  SHA512:
6
- metadata.gz: f395456c7fb73de0c9f7cc26963c5047ead2fdb971bd5f0ca09151320dafe58993a4530c577df1eb35e101a59a42f09e1d0bcbfa70e14393f71ea1d0cd946d79
7
- data.tar.gz: 53af867be8b8bfcf91d04e52780e0fbfe405a2d593809c982385a8cf54ee805b6dbe985a69a263ed8567fc723032cf04fb0e505b27d7a8608cef746ae03716ec
6
+ metadata.gz: 1f9ce8fb50712c0289704ac649cf47dfdca1cac6649068e0bcfd559150f7c953129f9a56cb3d98cbd9d7418045addc1e56346cf851054d9c428173ecb7177ac7
7
+ data.tar.gz: 5dedf835404390aed3d7880adc4a4cbf0b5f452ceb59485f1af32df7a9966ca78d4948747e1b71b91ee2b7bc3525245fcd28fc9ecce38c8e3f173fadebe023c5
@@ -44,6 +44,8 @@ module Kitchen
44
44
 
45
45
  default_config :inspec_tests, []
46
46
  default_config :load_plugins, true
47
+ default_config :plugin_config, {}
48
+ default_config :backend_cache, true
47
49
 
48
50
  # A lifecycle method that should be invoked when the object is about
49
51
  # ready to be used. A reference to an Instance is required as
@@ -81,29 +83,23 @@ module Kitchen
81
83
  # add inputs
82
84
  setup_inputs(opts, config)
83
85
 
84
- # setup logger
86
+ # setup Inspec
85
87
  ::Inspec::Log.init(STDERR)
86
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)
87
91
 
88
- # load plugins
89
- if config[:load_plugins]
90
- v2_loader = ::Inspec::Plugin::V2::Loader.new
91
- v2_loader.load_all
92
- v2_loader.exit_on_load_error
93
-
94
- if ::Inspec::InputRegistry.instance.respond_to?(:cache_inputs=) && config[:cache_inputs]
95
- ::Inspec::InputRegistry.instance.cache_inputs = !!config[:cache_inputs]
96
- end
97
- end
92
+ # handle plugins
93
+ setup_plugin_config(inspec_config)
98
94
 
99
95
  # initialize runner
100
- runner = ::Inspec::Runner.new(opts)
96
+ runner = ::Inspec::Runner.new(inspec_config)
101
97
 
102
98
  # add each profile to runner
103
99
  tests = collect_tests
104
100
  profile_ctx = nil
105
101
  tests.each do |target|
106
- profile_ctx = runner.add_target(target, opts)
102
+ profile_ctx = runner.add_target(target)
107
103
  end
108
104
 
109
105
  profile_ctx ||= []
@@ -145,6 +141,32 @@ module Kitchen
145
141
  end
146
142
  end
147
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
+
148
170
  # (see Base#load_needed_dependencies!)
149
171
  def load_needed_dependencies!
150
172
  require "inspec"
@@ -291,6 +313,7 @@ module Kitchen
291
313
  opts["bastion_port"] = kitchen[:ssh_gateway_port] if kitchen[:ssh_gateway_port]
292
314
  opts["key_files"] = kitchen[:keys] unless kitchen[:keys].nil?
293
315
  opts["password"] = kitchen[:password] unless kitchen[:password].nil?
316
+ opts["forward_agent"] = config[:forward_agent] || kitchen[:forward_agent] if config[:forward_agent] || kitchen[:forward_agent]
294
317
  opts
295
318
  end
296
319
 
@@ -20,6 +20,6 @@
20
20
  module Kitchen
21
21
  module Verifier
22
22
  # Version string for InSpec Kitchen verifier
23
- INSPEC_VERSION = "2.2.2".freeze
23
+ INSPEC_VERSION = "2.5.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.2.2
4
+ version: 2.5.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-12-11 00:00:00.000000000 Z
11
+ date: 2021-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inspec
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '2.7'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '3'
42
+ version: '4'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '2.7'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '3'
52
+ version: '4'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: hashie
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -57,9 +57,9 @@ dependencies:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '3.4'
60
- - - "<"
60
+ - - "<="
61
61
  - !ruby/object:Gem::Version
62
- version: '5'
62
+ version: '5.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,9 +67,9 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.4'
70
- - - "<"
70
+ - - "<="
71
71
  - !ruby/object:Gem::Version
72
- version: '5'
72
+ version: '5.0'
73
73
  description: A Test Kitchen Verifier for InSpec
74
74
  email:
75
75
  - info@chef.io
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.0.3
102
+ rubygems_version: 3.1.4
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: A Test Kitchen Verifier for InSpec