/* IO helpers — Thin wrappers for filesystem and system operations. Isolated here so tests can verify logic without needing OS-level mocks. Copyright (c) Armored Gates LLC. All rights reserved. */ package deploy import ( "os" "os/exec" ) // readFile reads a file's contents. Wraps os.ReadFile. func readFile(path string) ([]byte, error) { return os.ReadFile(path) } // writeFile writes data to a file atomically. Wraps os.WriteFile. func writeFile(path string, data []byte) error { return os.WriteFile(path, data, 0644) } // appendFile appends data to a file, creating it if necessary. func appendFile(path string, data []byte) error { f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { return err } defer f.Close() _, err = f.Write(data) return err } // fileInfo returns os.FileInfo for the given path. func fileInfo(path string) (os.FileInfo, error) { return os.Stat(path) } // runSystemctl runs a systemctl subcommand. func runSystemctl(action, unit string) error { cmd := exec.Command("systemctl", action, unit) _, err := cmd.CombinedOutput() return err }