Skip to content

Commit

Permalink
Accept inputs under new names
Browse files Browse the repository at this point in the history
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
  • Loading branch information
clintoncwolfe committed Jun 5, 2019
1 parent cb518fe commit 0822da6
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions lib/kitchen/verifier/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ def call(state)
opts = runner_options(instance.transport, state, instance.platform.name, instance.suite.name)
logger.debug "Options #{opts.inspect}"

# add attributes
opts[:attrs] = config[:attrs]
opts[:attributes] = Hashie.stringify_keys config[:attributes] unless config[:attributes].nil?
# add inputs
setup_inputs(opts, config)

# setup logger
::Inspec::Log.init(STDERR)
Expand Down Expand Up @@ -100,6 +99,31 @@ def call(state)

private

def setup_inputs(opts, config)
inspec_version = Gem::Version.new(::Inspec::VERSION)

# Handle input files
if config[:attrs]
logger.warn("kitchen-inspec: please use 'input-files' instead of 'attrs'")
config[:input_files] = config[:attrs]
end
if config[:input_files]
# Note that inspec expects the singular inflection, input_file
files_key = inspec_version >= Gem::Version.new('3.10') ? :input_file : :attrs
opts[files_key] = config[:input_files]
end

# Handle YAML => Hash inputs
if config[:attributes]
logger.warn("kitchen-inspec: please use 'inputs' instead of 'attributes'")
config[:inputs] = config[:attributes]
end
if config[:inputs]
inputs_key = inspec_version >= Gem::Version.new('3.11') ? :inputs : :attributes
opts[inputs_key] = Hashie.stringify_keys config[:inputs]
end
end

# (see Base#load_needed_dependencies!)
def load_needed_dependencies!
require "inspec"
Expand Down

0 comments on commit 0822da6

Please sign in to comment.