75d7b4389a
Signed-off-by: Alejandro Mery <amery@jpi.io>
30 lines
508 B
Go
30 lines
508 B
Go
package zones
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
"path/filepath"
|
|
)
|
|
|
|
// ReadFile reads a file from the machine's config directory
|
|
func (m *Machine) ReadFile(name string, args ...any) ([]byte, error) {
|
|
base := m.zone.zones.dir
|
|
fullName := m.getFilename(name, args...)
|
|
|
|
return fs.ReadFile(base, fullName)
|
|
}
|
|
|
|
func (m *Machine) getFilename(name string, args ...any) string {
|
|
if len(args) > 0 {
|
|
name = fmt.Sprintf(name, args...)
|
|
}
|
|
|
|
s := []string{
|
|
m.zone.Name,
|
|
m.Name,
|
|
name,
|
|
}
|
|
|
|
return filepath.Join(s...)
|
|
}
|