lib/kitchen/docker/helpers/cli_helper.rb in kitchen-docker-2.11.0 vs lib/kitchen/docker/helpers/cli_helper.rb in kitchen-docker-2.12.0
- old
+ new
@@ -34,10 +34,30 @@
docker << " --tlskey=#{config[:tls_key]}" if config[:tls_key]
logger.debug("docker_command: #{docker} #{cmd} shell_opts: #{docker_shell_opts(options)}")
run_command("#{docker} #{cmd}", docker_shell_opts(options))
end
+ # Copied from kitchen because we need stderr
+ def run_command(cmd, options = {})
+ if options.fetch(:use_sudo, false)
+ cmd = "#{options.fetch(:sudo_command, "sudo -E")} #{cmd}"
+ end
+ subject = "[#{options.fetch(:log_subject, "local")} command]"
+
+ debug("#{subject} BEGIN (#{cmd})")
+ sh = Mixlib::ShellOut.new(cmd, shell_opts(options))
+ sh.run_command
+ debug("#{subject} END #{Util.duration(sh.execution_time)}")
+ sh.error!
+ sh.stdout + sh.stderr
+ rescue Mixlib::ShellOut::ShellCommandFailed => ex
+ raise ShellCommandFailed, ex.message
+ rescue Exception => error # rubocop:disable Lint/RescueException
+ error.extend(Kitchen::Error)
+ raise
+ end
+
def build_run_command(image_id, transport_port = nil)
cmd = 'run -d'
cmd << ' -i' if config[:interactive]
cmd << ' -t' if config[:tty]
cmd << build_env_variable_args(config[:env_variables]) if config[:env_variables]
@@ -62,9 +82,10 @@
cmd << ' --privileged' if config[:privileged]
cmd << " --isolation #{config[:isolation]}" if config[:isolation]
Array(config[:cap_add]).each { |cap| cmd << " --cap-add=#{cap}"} if config[:cap_add]
Array(config[:cap_drop]).each { |cap| cmd << " --cap-drop=#{cap}"} if config[:cap_drop]
Array(config[:security_opt]).each { |opt| cmd << " --security-opt=#{opt}"} if config[:security_opt]
+ cmd << " --platform=#{config[:docker_platform]}" if config[:docker_platform]
extra_run_options = config_to_options(config[:run_options])
cmd << " #{extra_run_options}" unless extra_run_options.empty?
cmd << " #{image_id} #{config[:run_command]}"
logger.debug("build_run_command: #{cmd}")
cmd