Skip to content

Commit 4d8c2a7

Browse files
committed
bib: simplify saveManifest()
Just use os.WriteFile() intead of reimplementing it.
1 parent 2d62bcb commit 4d8c2a7

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

bib/cmd/bootc-image-builder/main.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"encoding/json"
5-
"errors"
65
"fmt"
76
"io"
87
"io/fs"
@@ -63,15 +62,7 @@ func saveManifest(ms manifest.OSBuildManifest, fpath string) (err error) {
6362
return fmt.Errorf("failed to marshal data for %q: %s", fpath, err.Error())
6463
}
6564
b = append(b, '\n') // add new line at end of file
66-
fp, err := os.Create(fpath)
67-
if err != nil {
68-
return fmt.Errorf("failed to create output file %q: %s", fpath, err.Error())
69-
}
70-
defer func() { err = errors.Join(err, fp.Close()) }()
71-
if _, err := fp.Write(b); err != nil {
72-
return fmt.Errorf("failed to write output file %q: %s", fpath, err.Error())
73-
}
74-
return nil
65+
return os.WriteFile(fpath, b, 0644)
7566
}
7667

7768
// manifestFromCobra generate an osbuild manifest from a cobra commandline.

0 commit comments

Comments
 (0)