From bdf0192ac5d507327c5bd810d67fa43cbdc35a68 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sun, 29 Oct 2023 00:49:56 +0000 Subject: [PATCH] cluster: add MkdirAll() support Signed-off-by: Alejandro Mery --- pkg/cluster/cluster_file.go | 9 +++++++++ pkg/cluster/machine_file.go | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/cluster/cluster_file.go b/pkg/cluster/cluster_file.go index e1deb11..1843274 100644 --- a/pkg/cluster/cluster_file.go +++ b/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) } + +// 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) +} diff --git a/pkg/cluster/machine_file.go b/pkg/cluster/machine_file.go index 69d4c23..9e037f7 100644 --- a/pkg/cluster/machine_file.go +++ b/pkg/cluster/machine_file.go @@ -74,6 +74,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...)