Complete infrastructure platform CLI: - Container runtime (systemd-nspawn) - VoltVisor VMs (Neutron Stardust / QEMU) - Stellarium CAS (content-addressed storage) - ORAS Registry - GitOps integration - Landlock LSM security - Compose orchestration - Mesh networking Copyright (c) Armored Gates LLC. All rights reserved. Licensed under AGPSL v5.0
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
/*
|
|
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
|
|
}
|