class Kitchen::Verifier::Shell
Shell
verifier for Kitchen
. This verifier just execute shell command from local.
@author SAWANOBORI Yukihiko (<sawanoboriyu@higanworks.com>)
Public Instance Methods
call(state)
click to toggle source
(see Base#call
)
# File lib/kitchen/verifier/shell.rb, line 39 def call(state) info("[#{name}] Verify on instance #{instance.name} with state=#{state}") sleep_if_set merge_state_to_env(state) if config[:remote_exec] instance.transport.connection(state) do |conn| conn.execute(config[:command]) end else shellout end debug("[#{name}] Verify completed.") end
run_command()
click to toggle source
for legacy drivers.
# File lib/kitchen/verifier/shell.rb, line 54 def run_command if config[:remote_exec] config[:command] else shellout nil end end
Private Instance Methods
merge_state_to_env(state)
click to toggle source
# File lib/kitchen/verifier/shell.rb, line 86 def merge_state_to_env(state) env_state = { environment: {} } env_state[:environment]["KITCHEN_INSTANCE"] = instance.name env_state[:environment]["KITCHEN_PLATFORM"] = instance.platform.name env_state[:environment]["KITCHEN_SUITE"] = instance.suite.name env_state[:environment]["KITCHEN_USERNAME"] = instance.transport[:username] if instance.respond_to?(:transport) state.each_pair do |key, value| env_state[:environment]["KITCHEN_" + key.to_s.upcase] = value.to_s end config[:shellout_opts].merge!(env_state) end
shellout()
click to toggle source
# File lib/kitchen/verifier/shell.rb, line 75 def shellout cmd = Mixlib::ShellOut.new(config[:command], config[:shellout_opts]) cmd.live_stream = config[:live_stream] cmd.run_command begin cmd.error! rescue Mixlib::ShellOut::ShellCommandFailed raise ActionFailed, "Action #verify failed for #{instance.to_str}." end end
sleep_if_set()
click to toggle source
Sleep for a period of time, if a value is set in the config.
@api private
# File lib/kitchen/verifier/shell.rb, line 68 def sleep_if_set config[:sleep].to_i.times do info(".") sleep 1 end end