cluster: introduce Cluster.RemoveFile()

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-10-29 01:04:54 +00:00
parent 7ea3906d63
commit 67d06084b5
2 changed files with 16 additions and 8 deletions
+15
View File
@@ -40,6 +40,21 @@ func (m *Cluster) openWriter(name string, flags int, args ...any) (io.WriteClose
panic("unreachable")
}
// RemoveFile deletes a file from the cluster's config directory
func (m *Cluster) RemoveFile(name string, args ...any) error {
if len(args) > 0 {
name = fmt.Sprintf(name, args...)
}
err := fs.Remove(m.dir, name)
switch {
case os.IsNotExist(err):
return nil
default:
return err
}
}
// ReadFile reads a file from the cluster's config directory
func (m *Cluster) ReadFile(name string, args ...any) ([]byte, error) {
if len(args) > 0 {