mirror of https://github.com/knative/func.git
fix: closing stdout
pack client was closing stdout this commit prevents that Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
e7b0c375d4
commit
6f40b29d3e
|
@ -95,7 +95,9 @@ func (builder *Builder) Build(ctx context.Context, f fn.Function) (err error) {
|
|||
// log output is either STDOUt or kept in a buffer to be printed on error.
|
||||
var logWriter io.Writer
|
||||
if builder.Verbose {
|
||||
logWriter = os.Stdout
|
||||
// pass stdout as non-closeable writer
|
||||
// otherwise pack client would close it which is bad
|
||||
logWriter = stdoutWrapper{os.Stdout}
|
||||
} else {
|
||||
logWriter = &bytes.Buffer{}
|
||||
}
|
||||
|
@ -129,6 +131,15 @@ func (builder *Builder) Build(ctx context.Context, f fn.Function) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// hack this makes stdout non-closeable
|
||||
type stdoutWrapper struct {
|
||||
impl io.Writer
|
||||
}
|
||||
|
||||
func (s stdoutWrapper) Write(p []byte) (n int, err error) {
|
||||
return s.impl.Write(p)
|
||||
}
|
||||
|
||||
type clientWrapper struct {
|
||||
impl dockerClient.CommonAPIClient
|
||||
}
|
||||
|
|
|
@ -153,8 +153,6 @@ func TestRemove(t *testing.T) {
|
|||
// newClient creates an instance of the func client whose concrete impls
|
||||
// match those created by the kn func plugin CLI.
|
||||
func newClient(verbose bool) *boson.Client {
|
||||
// TODO: Forcing verbose to false in order to pass integration tests
|
||||
verbose = false
|
||||
builder := buildpacks.NewBuilder()
|
||||
builder.Verbose = verbose
|
||||
|
||||
|
|
Loading…
Reference in New Issue