From 527f9af1d1bf7607997c8c131580aa2c93852639 Mon Sep 17 00:00:00 2001 From: Thomas Heinen Date: Wed, 8 Jan 2020 18:25:54 +0100 Subject: [PATCH 1/2] Add feature to load Inspec plugins for additional functionality Signed-off-by: Thomas Heinen --- README.md | 9 +++++++++ lib/kitchen/verifier/inspec.rb | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 5e09530..4aff780 100644 --- a/README.md +++ b/README.md @@ -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 verified does not load Inspec plugins like additional inputs. 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. diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index 740e1c9..bcd7da9 100644 --- a/lib/kitchen/verifier/inspec.rb +++ b/lib/kitchen/verifier/inspec.rb @@ -26,6 +26,8 @@ require "pathname" require "hashie" +require "inspec/plugin/v2" + module Kitchen module Verifier # InSpec verifier for Kitchen. @@ -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 @@ -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 From 02fdd51930def3ddfa67e5c733dde78f142c7ed0 Mon Sep 17 00:00:00 2001 From: Thomas Heinen Date: Tue, 21 Jan 2020 17:19:20 +0100 Subject: [PATCH 2/2] Add small fix in README Signed-off-by: Thomas Heinen --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4aff780..2e13148 100644 --- a/README.md +++ b/README.md @@ -268,7 +268,7 @@ You can also define your inputs in external files. Adapt your `.kitchen.yml` to ### Use inspec plugins -By default, the verified does not load Inspec plugins like additional inputs. You can activate loading the same plugins as on normal Inspec invocations: +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: