From cfed194bd1f42f9e90a99113a4ce779931e287d9 Mon Sep 17 00:00:00 2001 From: Tristan Colgate-McFarlane Date: Tue, 5 Mar 2024 15:25:20 +0000 Subject: [PATCH] error on marshal failure --- cmd/reimage/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/reimage/main.go b/cmd/reimage/main.go index 4aa5194..2173625 100644 --- a/cmd/reimage/main.go +++ b/cmd/reimage/main.go @@ -290,14 +290,19 @@ func (a *app) readStaticMappings(confirmDigests bool) (*reimage.StaticRemapper, } func (a *app) writeMappings(mappings map[string]reimage.QualifiedImage) (err error) { - bs, _ := json.Marshal(mappings) + bs, err := json.Marshal(mappings) + if err != nil { + return fmt.Errorf("could not marshal mappings, %w", err) + } if a.DryRun { a.log.Info("dry-run, will not write static mappings file") return nil } + a.log.Info("writing mappings file", "file", a.WriteMappings) if a.WriteMappings != "" { + a.log.Info("writing mappings file", "file", a.WriteMappings) err = os.WriteFile(a.WriteMappings, bs, 0644) if err != nil { return fmt.Errorf("could not write file, %w", err)