class KubeDeployTools::Shellrunner
Attributes
shellrunner[RW]
Public Class Methods
new()
click to toggle source
# File lib/kube_deploy_tools/shellrunner.rb, line 16 def initialize end
Public Instance Methods
check_call(*cmd, **opts)
click to toggle source
# File lib/kube_deploy_tools/shellrunner.rb, line 19 def check_call(*cmd, **opts) out, err, status = run_call(*cmd, **opts) if !status.success? raise "Command failed: #{Shellwords.join(cmd)} with the following error: #{err}" end out end
run_call(*cmd, **opts)
click to toggle source
# File lib/kube_deploy_tools/shellrunner.rb, line 27 def run_call(*cmd, **opts) print_cmd = opts.fetch(:print_cmd, true) if print_cmd Logger.info(Shellwords.join(cmd)) else Logger.debug(Shellwords.join(cmd)) end out, err, status = Open3.capture3(*cmd, stdin_data: opts[:stdin_data]) Logger.debug(out.shellescape) if !status.success? && print_cmd Logger.warn("The following command failed: #{Shellwords.join(cmd)}") Logger.warn(err) end [out.chomp, err.chomp, status] end