jpictl: create machine directories on jpictl write #33

Merged
amery merged 3 commits from pr-amery-mkdirall into main 2023-10-30 19:47:38 +01:00
2 changed files with 16 additions and 0 deletions
Showing only changes of commit 57e1077a85 - Show all commits
+9
View File
@@ -104,3 +104,12 @@ func (m *Cluster) WriteStringFile(value string, name string, args ...any) error
_, err = buf.WriteTo(f)
return err
}
// 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
View File
@@ -60,6 +60,13 @@ func (m *Machine) WriteStringFile(value string, name string, args ...any) error
return m.zone.zones.WriteStringFile(value, fullName)
}
// 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...)