Skip to content

Commit

Permalink
Format k8s logs so we get a proper new line for nmstate
Browse files Browse the repository at this point in the history
  • Loading branch information
qinqon committed Sep 30, 2019
1 parent ec93f69 commit 5e8974f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os/exec"
"strings"
"testing"
Expand Down Expand Up @@ -57,12 +58,13 @@ func writePodsLogs(namespace string, sinceTime time.Time, writer io.Writer) erro
continue
}
defer podLogs.Close()
_, err = io.Copy(writer, podLogs)
rawLogs, err := ioutil.ReadAll(podLogs)
if err != nil {
io.WriteString(writer, fmt.Sprintf("error in copy information from podLogs to buf: %v\n", err))
io.WriteString(writer, fmt.Sprintf("error reading kubernetes-nmstate logs: %v\n", err))
continue
}

formattedLogs := strings.Replace(string(rawLogs), "\\n", "\n", -1)
io.WriteString(writer, formattedLogs)
}
return nil
}
Expand Down

0 comments on commit 5e8974f

Please sign in to comment.