Merge branch 'pr-amery-mkdirall' into next-amery
This commit is contained in:
@@ -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...)
|
||||
|
||||
@@ -3,6 +3,7 @@ package cluster
|
||||
// SyncAll updates all config files
|
||||
func (m *Cluster) SyncAll() error {
|
||||
for _, fn := range []func() error{
|
||||
m.SyncMkdirAll,
|
||||
m.SyncAllWireguard,
|
||||
m.SyncAllCeph,
|
||||
m.WriteHosts,
|
||||
@@ -15,6 +16,20 @@ func (m *Cluster) SyncAll() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SyncMkdirAll creates the directories needed to store files
|
||||
// required to represent the cluster.
|
||||
func (m *Cluster) SyncMkdirAll() error {
|
||||
err := m.MkdirAll(".")
|
||||
if err == nil {
|
||||
m.ForEachMachine(func(p *Machine) bool {
|
||||
err = p.MkdirAll(".")
|
||||
return err != nil
|
||||
})
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SyncAllWireguard updates all wireguard config files
|
||||
func (m *Cluster) SyncAllWireguard() error {
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user