Skip to content

Commit

Permalink
Merge pull request #4 from chef/fnichol/full-ssh-tunables
Browse files Browse the repository at this point in the history
Support all Kitchen/SSH as Train/SSH tunables.
  • Loading branch information
arlimus committed Oct 26, 2015
2 parents 82b5412 + 2008d11 commit a95de00
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ group :test do
end

gem "inspec", :git => "[email protected]:chef/inspec.git"
gem 'train', git: '[email protected]:chef/train.git'
gem "train", :git => "[email protected]:chef/train.git"
25 changes: 19 additions & 6 deletions lib/kitchen/verifier/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,29 @@ def local_suite_files
# @return [Hash] a configuration hash of string-based keys
# @api private
def runner_options_for_ssh(config_data)
opts = instance.transport.send(:connection_options, config_data).dup
{
kitchen = instance.transport.send(:connection_options, config_data).dup

opts = {
"backend" => "ssh",
"host" => opts[:hostname],
"port" => opts[:port],
"user" => opts[:username],
"key_files" => opts[:keys],
"logger" => logger,
# pass-in sudo config from kitchen verifier
"sudo" => config[:sudo],
"host" => kitchen[:hostname],
"port" => kitchen[:port],
"user" => kitchen[:username],
"keepalive" => kitchen[:keepalive],
"keepalive_interval" => kitchen[:keepalive_interval],
"connection_timeout" => kitchen[:timeout],
"connection_retries" => kitchen[:connection_retries],
"connection_retry_sleep" => kitchen[:connection_retry_sleep],
"max_wait_until_ready" => kitchen[:max_wait_until_ready],
"compression" => kitchen[:compression],
"compression_level" => kitchen[:compression_level]
}
opts["key_files"] = kitchen[:keys] unless kitchen[:keys].nil?
opts["password"] = kitchen[:password] unless kitchen[:password].nil?

opts
end
end
end
Expand Down
22 changes: 21 additions & 1 deletion spec/kitchen/verifier/inspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@
:hostname => "boogie",
:port => "I shouldn't be used",
:username => "dance",
:ssh_key => "/backstage/pass"
:ssh_key => "/backstage/pass",
:keepalive => "keepalive",
:keepalive_interval => "forever",
:connection_timeout => "nope",
:connection_retries => "thousand",
:connection_retry_sleep => "sleepy",
:max_wait_until_ready => 42,
:compression => "maxyo",
:compression_level => "pico"
}
end

Expand All @@ -114,12 +122,24 @@
end

it "constructs a Inspec::Runner using transport config data and state" do
config[:sudo] = "jellybeans"

expect(Inspec::Runner).to receive(:new).
with(hash_including(
"backend" => "ssh",
"logger" => logger,
"sudo" => "jellybeans",
"host" => "boogie",
"port" => 123,
"user" => "dance",
"keepalive" => "keepalive",
"keepalive_interval" => "forever",
"connection_timeout" => "nope",
"connection_retries" => "thousand",
"connection_retry_sleep" => "sleepy",
"max_wait_until_ready" => 42,
"compression" => "maxyo",
"compression_level" => "pico",
"key_files" => ["/backstage/pass"]
)).
and_return(runner)
Expand Down

0 comments on commit a95de00

Please sign in to comment.