Skip to content

Commit

Permalink
Use std lib os.WriteFile()
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
  • Loading branch information
marceloneppel committed Aug 19, 2024
1 parent 3035631 commit 80f4440
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions microceph/ceph/rgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func EnableRGW(s interfaces.StateInterface, port int, sslPort int, sslCertificat
if err != nil {
return err
}
err = writeFile(sslCertificatePath, string(decodedSSLCertificate), 0600)
err = os.WriteFile(sslCertificatePath, decodedSSLCertificate, 0600)
if err != nil {
return err
}
Expand All @@ -35,7 +35,7 @@ func EnableRGW(s interfaces.StateInterface, port int, sslPort int, sslCertificat
if err != nil {
return err
}
err = writeFile(sslPrivateKeyPath, string(decodedSSLPrivateKey), 0600)
err = os.WriteFile(sslPrivateKeyPath, decodedSSLPrivateKey, 0600)
if err != nil {
return err
}
Expand Down Expand Up @@ -190,17 +190,3 @@ func symlinkRGWKeyring(keyPath, ConfPath string) error {

return nil
}

func writeFile(path, data string, mode int) error {
fd, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_RDWR, os.FileMode(mode))
if err != nil {
return fmt.Errorf("Couldn't open %s: %w", path, err)
}
defer fd.Close()

_, err = fd.Write([]byte(data))
if err != nil {
return fmt.Errorf("Couldn't write to %s: %w", path, err)
}
return nil
}

0 comments on commit 80f4440

Please sign in to comment.