Centralize deterministic JSON file writing
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package report
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
)
|
||||
import "gitea.maximumdirect.net/eric/seriatim/internal/jsonfile"
|
||||
|
||||
// Severity classifies report events.
|
||||
type Severity string
|
||||
@@ -62,13 +59,5 @@ func Warning(stage string, module string, message string) Event {
|
||||
|
||||
// WriteJSON writes a deterministic JSON report.
|
||||
func WriteJSON(path string, rpt Report) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
enc := json.NewEncoder(file)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(rpt)
|
||||
return jsonfile.Write(path, rpt)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user