class Kitchen::Transport::Kubernetes::Connection
Public Instance Methods
execute(command)
click to toggle source
(see Base::Connection#execute)
# File lib/kitchen/transport/kubernetes.rb, line 57 def execute(command) return if command.nil? # Run via kubectl exec. run_command(kubectl_command('exec', '--tty', '--container=default', options[:pod_id], '--', *Shellwords.split(command))) end
login_command()
click to toggle source
(see Base::Connection#login_command)
# File lib/kitchen/transport/kubernetes.rb, line 71 def login_command # Find a valid login shell and exec it. This is so weridly complex # because it has to work with a /bin/sh that might be bash, dash, or # busybox. Also CentOS images doesn't have `which` for some reason. # Dash's `type` is super weird so use `which` first in case of dash but # fall back to `type` for basically just CentOS. login_cmd = "IFS=$'\n'; for f in `which bash zsh sh 2>/dev/null || type -P bash zsh sh`; do exec \"$f\" -l; done" cmd = kubectl_command('exec', '--stdin', '--tty', '--container=default', options[:pod_id], '--', '/bin/sh', '-c', login_cmd) LoginCommand.new(cmd[0], cmd.drop(1)) end
upload(locals, remote)
click to toggle source
(see Base::Connection#upload)
# File lib/kitchen/transport/kubernetes.rb, line 64 def upload(locals, remote) return if locals.empty? # Use rsync over kubectl exec to send files. run_command([options[:rsync_command], '--archive', '--progress', '--blocking-io', '--rsh', options[:rsync_rsh]] + (options[:log_level] == :debug ? %w{--verbose --verbose --verbose} : []) + locals + ["#{options[:pod_id]}:#{remote}"]) end