Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to load Inspec plugins for additional functionality #247

Merged
merged 2 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@ You can also define your inputs in external files. Adapt your `.kitchen.yml` to
- test/integration/profile-attribute.yml
```

### Use inspec plugins

By default, the verifier does not load Inspec plugins such as additional input plugins. You can activate loading the same plugins as on normal Inspec invocations:

```yaml
verifier:
load_plugins: true
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down
10 changes: 10 additions & 0 deletions lib/kitchen/verifier/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
require "pathname"
require "hashie"

require "inspec/plugin/v2"

module Kitchen
module Verifier
# InSpec verifier for Kitchen.
Expand All @@ -36,6 +38,7 @@ class Inspec < Kitchen::Verifier::Base # rubocop:disable Metrics/ClassLength
plugin_version Kitchen::Verifier::INSPEC_VERSION

default_config :inspec_tests, []
default_config :load_plugins, false

# A lifecycle method that should be invoked when the object is about
# ready to be used. A reference to an Instance is required as
Expand Down Expand Up @@ -80,6 +83,13 @@ def call(state)
# initialize runner
runner = ::Inspec::Runner.new(opts)

# load plugins
if config[:load_plugins]
v2_loader = ::Inspec::Plugin::V2::Loader.new
v2_loader.load_all
v2_loader.exit_on_load_error
end

# add each profile to runner
tests = collect_tests
profile_ctx = nil
Expand Down