class Kitchen::Transport::Connection

Connection class for Kitchen

Public Instance Methods

execute(command) click to toggle source

(see Base::Connection#execute)

# File lib/kitchen/transport/k8s.rb, line 33
def execute(command)
  return if command.nil?
  run_command(kubectl_command('exec', '--tty', '--container=default', options[:pod_id], '--', *Shellwords.split(wrap_command(command))))
end
upload(locals, remote) click to toggle source

(see Base::Connection#upload)

# File lib/kitchen/transport/k8s.rb, line 39
def upload(locals, remote)
  return if locals.empty?
  locals.each do |local|
    full_remote = "#{options[:namespace]}/#{options[:pod_id]}:#{remote}"
    run_command(kubectl_command('cp', local, full_remote, '-c', 'default'))
  end
end

Protected Instance Methods

wrap_command(cmd) click to toggle source
# File lib/kitchen/transport/k8s.rb, line 49
def wrap_command(cmd)
  cmd.match(/\Ash\s\-c/) ? cmd : Util.wrap_command(cmd.gsub('\'', "'\\\\''"))
end