Browse Source

cluster: add MkdirAll() support

Signed-off-by: Alejandro Mery <amery@jpi.io>
Alejandro Mery 1 year ago
parent
commit
bdf0192ac5
  1. 9
      pkg/cluster/cluster_file.go
  2. 7
      pkg/cluster/machine_file.go

9
pkg/cluster/cluster_file.go

@ -48,3 +48,12 @@ func (m *Cluster) ReadFile(name string, args ...any) ([]byte, error) {
return fs.ReadFile(m.dir, name) 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)
}

7
pkg/cluster/machine_file.go

@ -74,6 +74,13 @@ func (m *Machine) WriteStringFile(value string, name string, args ...any) error
return err 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 { func (m *Machine) getFilename(name string, args ...any) string {
if len(args) > 0 { if len(args) > 0 {
name = fmt.Sprintf(name, args...) name = fmt.Sprintf(name, args...)

Loading…
Cancel
Save