class Train::Transports::KubernetesHack::Connection
Public Instance Methods
file(path)
click to toggle source
# File lib/kitchen/verifier/train_kubernetes_hack.rb, line 52 def file(path) @files[path] ||= file_via_connection(path) end
file_via_connection(path)
click to toggle source
# File lib/kitchen/verifier/train_kubernetes_hack.rb, line 61 def file_via_connection(path) defined?(Train::File::Remote::Linux) ? Train::File::Remote::Linux.new(self, path) : LinuxFile.new(self, path) end
os()
click to toggle source
The API for a connection changed a lot in 0.30, this is a compat shim.
# File lib/kitchen/verifier/train_kubernetes_hack.rb, line 48 def os @os ||= OSCommon.new(self, family: 'unix') end
run_command(cmd)
click to toggle source
# File lib/kitchen/verifier/train_kubernetes_hack.rb, line 56 def run_command(cmd) run_command_via_connection(cmd) end
run_command_via_connection(cmd)
click to toggle source
# File lib/kitchen/verifier/train_kubernetes_hack.rb, line 65 def run_command_via_connection(cmd) kubectl_cmd = [options[:kubectl_path], 'exec'] kubectl_cmd.concat(['--context', options[:context]]) if options[:context] kubectl_cmd.concat(['--container', options[:container]]) if options[:container] kubectl_cmd.concat([options[:pod], '--', '/bin/sh', '-c', cmd]) so = Mixlib::ShellOut.new(kubectl_cmd, logger: logger) so.run_command if so.error? # Trim the "command terminated with exit code N" line from the end # of the stderr content. so.stderr.gsub!(/command terminated with exit code #{so.exitstatus}\n\Z/, '') end CommandResult.new(so.stdout, so.stderr, so.exitstatus) end
uri()
click to toggle source
# File lib/kitchen/verifier/train_kubernetes_hack.rb, line 81 def uri if options[:container] "kubernetes://#{options[:pod]}/#{options[:container]}" else "kubernetes://#{options[:pod]}" end end