lib/bolt/transport/docker/connection.rb in bolt-1.12.0 vs lib/bolt/transport/docker/connection.rb in bolt-1.13.0
- old
+ new
@@ -25,10 +25,11 @@
'CONNECT_ERROR'
)
end
def execute(*command, options)
+ command.unshift(options[:interpreter]) if options[:interpreter]
if options[:environment]
envs = options[:environment].map { |env, val| "#{env}=#{val}" }
command = ['env'] + envs + command
end
@@ -37,10 +38,12 @@
if result[2] == 0
@logger.debug { "Command returned successfully" }
else
@logger.info { "Command failed with exit code #{result[2]}" }
end
+ result[0] = result[0].join.force_encoding('UTF-8')
+ result[1] = result[1].join.force_encoding('UTF-8')
result
rescue StandardError
@logger.debug { "Command aborted" }
raise
end
@@ -60,22 +63,22 @@
end
def mkdirs(dirs)
_, stderr, exitcode = execute('mkdir', '-p', *dirs, {})
if exitcode != 0
- message = "Could not create directories: #{stderr.join}"
+ message = "Could not create directories: #{stderr}"
raise Bolt::Node::FileError.new(message, 'MKDIR_ERROR')
end
end
def make_tempdir
tmpdir = @target.options.fetch('tmpdir', '/tmp')
tmppath = "#{tmpdir}/#{SecureRandom.uuid}"
stdout, stderr, exitcode = execute('mkdir', '-m', '700', tmppath, {})
if exitcode != 0
- raise Bolt::Node::FileError.new("Could not make tempdir: #{stderr.join}", 'TEMPDIR_ERROR')
+ raise Bolt::Node::FileError.new("Could not make tempdir: #{stderr}", 'TEMPDIR_ERROR')
end
tmppath || stdout.first
end
def with_remote_tempdir
@@ -83,11 +86,11 @@
yield dir
ensure
if dir
_, stderr, exitcode = execute('rm', '-rf', dir, {})
if exitcode != 0
- @logger.warn("Failed to clean up tempdir '#{dir}': #{stderr.join}")
+ @logger.warn("Failed to clean up tempdir '#{dir}': #{stderr}")
end
end
end
def write_remote_executable(dir, file, filename = nil)
@@ -99,10 +102,10 @@
end
def make_executable(path)
_, stderr, exitcode = execute('chmod', 'u+x', path, {})
if exitcode != 0
- message = "Could not make file '#{path}' executable: #{stderr.join}"
+ message = "Could not make file '#{path}' executable: #{stderr}"
raise Bolt::Node::FileError.new(message, 'CHMOD_ERROR')
end
end
end
end