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

Added Runner Options for New Docker Transport #236

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ end
group :integration do
gem "berkshelf", ">= 4.3.5"
gem "kitchen-dokken"
gem "kitchen-docker", ">= 2.10.0"
end

group :tools do
Expand Down
3 changes: 3 additions & 0 deletions lib/kitchen/verifier/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ def runner_options_for_dockercli(config_data)
logger.debug "Connect to Container: #{opts['host']}"
opts
end

# Add alias for docker transport from kitchen-docker gem
alias_method :runner_options_for_docker, :runner_options_for_dockercli
end
end
end
34 changes: 34 additions & 0 deletions spec/kitchen/verifier/inspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
require "kitchen/transport/exec"
require "kitchen/transport/ssh"
require "kitchen/transport/winrm"
require "kitchen/transport/docker"

describe Kitchen::Verifier::Inspec do

Expand Down Expand Up @@ -664,6 +665,39 @@
end
end

context "with a docker transport" do

let(:transport) do
Kitchen::Transport::Docker.new
end

let(:runner) do
instance_double("Inspec::Runner")
end

before do
allow(runner).to receive(:add_target)
allow(runner).to receive(:run).and_return 0
end

it "constructs a Inspec::Runner using transport config data and state" do
expect(Inspec::Runner).to receive(:new)
.with(
hash_including(
"backend" => "docker",
:backend_cache => true,
"color" => true,
:controls => nil,
"host" => nil,
"logger" => logger
)
)
.and_return(runner)

verifier.call({})
end
end

context "with an unsupported transport" do

it "#call raises a UserError" do
Expand Down