Browse Source

jpictl: create machine directories on `jpictl write`

Signed-off-by: Alejandro Mery <amery@jpi.io>
Alejandro Mery 11 months ago
parent
commit
d036abd816
  1. 8
      pkg/cluster/machine_file.go
  2. 19
      pkg/cluster/sync.go

8
pkg/cluster/machine_file.go

@ -89,3 +89,11 @@ 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)
}

19
pkg/cluster/sync.go

@ -1,8 +1,13 @@
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.SyncAllWireguard,
m.SyncAllCeph,
m.WriteHosts,
@ -15,6 +20,20 @@ func (m *Cluster) SyncAll() error {
return nil
}
// MkdirAll creates the directories needed to store files
// required to represent the cluster.
func (m *Cluster) MkdirAll() error {
err := hackpadfs.MkdirAll(m.dir, ".", 0755)
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

Loading…
Cancel
Save