diff --git a/buildpacks/builder.go b/buildpacks/builder.go index 4380d2f3..7c93df75 100644 --- a/buildpacks/builder.go +++ b/buildpacks/builder.go @@ -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 } diff --git a/client_int_test.go b/client_int_test.go index 56fb5c10..1bc1d663 100644 --- a/client_int_test.go +++ b/client_int_test.go @@ -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