Skip to content

Commit

Permalink
error on marshal failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tcolgate committed Mar 5, 2024
1 parent 0511e49 commit cfed194
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/reimage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cfed194

Please sign in to comment.