Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b903ea957c | |||
| 9f0792cde6 |
@@ -48,3 +48,12 @@ func (m *Cluster) ReadFile(name string, args ...any) ([]byte, error) {
|
||||
|
||||
return fs.ReadFile(m.dir, name)
|
||||
}
|
||||
|
||||
// MkdirAll creates directories relative to the cluster's config directory
|
||||
func (m *Cluster) MkdirAll(name string, args ...any) error {
|
||||
if len(args) > 0 {
|
||||
name = fmt.Sprintf(name, args...)
|
||||
}
|
||||
|
||||
return fs.MkdirAll(m.dir, name, 0755)
|
||||
}
|
||||
|
||||
@@ -76,6 +76,13 @@ func (m *Machine) WriteStringFile(value string, name string, args ...any) error
|
||||
return err
|
||||
}
|
||||
|
||||
// MkdirAll creates directories relative to the machine's config directory
|
||||
func (m *Machine) MkdirAll(name string, args ...any) error {
|
||||
fullName := m.getFilename(name, args...)
|
||||
|
||||
return m.zone.zones.MkdirAll(fullName)
|
||||
}
|
||||
|
||||
func (m *Machine) getFilename(name string, args ...any) string {
|
||||
if len(args) > 0 {
|
||||
name = fmt.Sprintf(name, args...)
|
||||
@@ -89,11 +96,3 @@ func (m *Machine) getFilename(name string, args ...any) string {
|
||||
|
||||
return filepath.Join(s...)
|
||||
}
|
||||
|
||||
// MkdirAll creates the directory representing this [Machine]
|
||||
func (m *Machine) MkdirAll() error {
|
||||
base := m.zone.zones.dir
|
||||
fullName := m.getFilename(".")
|
||||
|
||||
return fs.MkdirAll(base, fullName, 0755)
|
||||
}
|
||||
|
||||
+5
-9
@@ -1,13 +1,9 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"github.com/hack-pad/hackpadfs"
|
||||
)
|
||||
|
||||
// SyncAll updates all config files
|
||||
func (m *Cluster) SyncAll() error {
|
||||
for _, fn := range []func() error{
|
||||
m.MkdirAll,
|
||||
m.SyncMkdirAll,
|
||||
m.SyncAllWireguard,
|
||||
m.SyncAllCeph,
|
||||
m.WriteHosts,
|
||||
@@ -20,13 +16,13 @@ func (m *Cluster) SyncAll() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MkdirAll creates the directories needed to store files
|
||||
// SyncMkdirAll creates the directories needed to store files
|
||||
// required to represent the cluster.
|
||||
func (m *Cluster) MkdirAll() error {
|
||||
err := hackpadfs.MkdirAll(m.dir, ".", 0755)
|
||||
func (m *Cluster) SyncMkdirAll() error {
|
||||
err := m.MkdirAll(".")
|
||||
if err == nil {
|
||||
m.ForEachMachine(func(p *Machine) bool {
|
||||
err = p.MkdirAll()
|
||||
err = p.MkdirAll(".")
|
||||
return err != nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user