From 1580c09746988aab59213f2ba8f07306491faf5d Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sun, 29 Oct 2023 23:45:19 +0000 Subject: [PATCH] cluster: add Machine.ReadLines() shortcut Signed-off-by: Alejandro Mery --- pkg/cluster/machine_file.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/cluster/machine_file.go b/pkg/cluster/machine_file.go index f4bb148..f182f47 100644 --- a/pkg/cluster/machine_file.go +++ b/pkg/cluster/machine_file.go @@ -53,6 +53,14 @@ func (m *Machine) ReadFile(name string, args ...any) ([]byte, error) { return m.zone.zones.ReadFile(fullName) } +// ReadLines reads a file from the machine's config directory, +// split by lines, trimmed, and accepting `#` to comment lines out. +func (m *Machine) ReadLines(name string, args ...any) ([]string, error) { + fullName := m.getFilename(name, args...) + + return m.zone.zones.ReadLines(fullName) +} + // WriteStringFile writes the given content to a file on the machine's config directory func (m *Machine) WriteStringFile(value string, name string, args ...any) error { fullName := m.getFilename(name, args...)