Add option for docker executor to handle stderr from results
Instead of always joining stdout and stderr, only join the two if the caller explicitly asks for it. Otherwise, only return stdout.
This commit is contained in:
parent
1699821571
commit
2901dae948
|
@ -20,9 +20,10 @@ module VagrantPlugins
|
|||
#
|
||||
# @return [String] id - ID matched from the docker build output.
|
||||
def build(dir, **opts, &block)
|
||||
args = Array(opts[:extra_args])
|
||||
args << dir
|
||||
result = execute('docker', 'build', *args, &block)
|
||||
args = Array(opts[:extra_args])
|
||||
args << dir
|
||||
opts = {with_stderr: true}
|
||||
result = execute('docker', 'build', *args, opts, &block)
|
||||
matches = result.match(/Successfully built (?<id>.+)$/i)
|
||||
if !matches
|
||||
# Check for the new output format 'writing image sha256...'
|
||||
|
|
|
@ -27,10 +27,12 @@ module VagrantPlugins
|
|||
stdout: result.stdout
|
||||
end
|
||||
|
||||
if result.stdout.to_s.strip.length == 0
|
||||
result.stderr
|
||||
else
|
||||
result.stdout
|
||||
if opts
|
||||
if opts[:with_stderr]
|
||||
return result.stdout + " " + result.stderr
|
||||
else
|
||||
return result.stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue