Build error formatting on fission spec apply --wait (#1403)
The character `\n` in buildlog stores in package status are escaped and so when we have to replace them with actual line breaker.
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
@@ -175,3 +176,15 @@ func DownloadStoragesvcURL(client *client.Client, fileUrl string) (io.ReadCloser
|
||||
|
||||
return reader, nil
|
||||
}
|
||||
|
||||
// PrintPackageSummary prints package information and build logs.
|
||||
func PrintPackageSummary(writer io.Writer, pkg *fv1.Package) {
|
||||
// replace escaped line breaker character
|
||||
buildlog := strings.ReplaceAll(pkg.Status.BuildLog, `\n`, "\n")
|
||||
w := tabwriter.NewWriter(writer, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "Name:", pkg.Metadata.Name)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "Environment:", pkg.Spec.Environment.Name)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "Status:", pkg.Status.BuildStatus)
|
||||
fmt.Fprintf(w, "%v\n%v", "Build Logs:", buildlog)
|
||||
w.Flush()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user