Pretty print osbuild JSON on failure

When osbuild fails, osbuild-composer's image tests print the output as
ugly JSON and that makes it difficult to determine why osbuild failed.

Instead, print the json in pretty format. 🦋

Fixes #782.

Signed-off-by: Major Hayden <major@redhat.com>
This commit is contained in:
Major Hayden 2020-06-18 08:01:13 -05:00 committed by Major Hayden
parent 282763a977
commit 4da9c3389b

View file

@ -63,7 +63,11 @@ func runOsbuild(manifest []byte, store, outputDirectory string) error {
err := cmd.Run()
if err != nil {
fmt.Println(outBuffer.String())
// Pretty print the osbuild error output.
buf := new(bytes.Buffer)
_ = json.Indent(buf, outBuffer.Bytes(), "", " ")
fmt.Println(buf)
return fmt.Errorf("running osbuild failed: %v", err)
}