Fixed: redirecting output to the buffer hangs when big string has to be redirected
@@ -1644,19 +1644,10 @@ func NewTestNamespace(injectKnativeBroker bool) ctrl.Object {
func GetOutputString(command *cobra.Command) string {
var buf bytes.Buffer
- reader, writer, err := os.Pipe()
- if err != nil {
- panic(err)
- }
- command.SetOut(writer)
+ command.SetOut(&buf)
command.Execute()
- writer.Close()
- defer reader.Close()
-
- buf.ReadFrom(reader)
-
return buf.String()
}
