summaryrefslogtreecommitdiff
path: root/internal/zfsutil/zfsutil.go
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-08-05 23:22:25 -0500
committerClaude <noreply@anthropic.com>2026-08-05 23:22:25 -0500
commitfc0c6951d7ac36dd8f30ace929991197dc99ae54 (patch)
tree46fa11cc103ebe7805bf42bc3e4bb105e6b49721 /internal/zfsutil/zfsutil.go
parent9f7c9f2f31acd7bc544dd988af1c8c2fe63ec504 (diff)
Simplify: centralize paths in layout, dedup zfs snapshot refs, remove dead code
- Add layout.Config methods (ReleasesDir, PostReceiveHookPath, RCScriptPath, RCConfPath) so main.go and jailmgr no longer hand-build paths that layout already owns. - Extract zfsutil.snapRef to replace three inline dataset@tag Sprintfs. - Remove seven unused exported functions (zfsutil.Exists, jailmgr.Stop, sh.RunWithStdinFile, and four dead layout.Config path methods) and their now-unused imports.
Diffstat (limited to 'internal/zfsutil/zfsutil.go')
-rw-r--r--internal/zfsutil/zfsutil.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/internal/zfsutil/zfsutil.go b/internal/zfsutil/zfsutil.go
index 3d3bd40..8f1b0e2 100644
--- a/internal/zfsutil/zfsutil.go
+++ b/internal/zfsutil/zfsutil.go
@@ -11,20 +11,18 @@ import (
"skiff/internal/sh"
)
-func Exists(ctx context.Context, dataset string) bool {
- _, err := sh.Output(ctx, "", "zfs", "list", "-H", "-o", "name", dataset)
- return err == nil
+func snapRef(dataset, tag string) string {
+ return fmt.Sprintf("%s@%s", dataset, tag)
}
// Clone creates a new dataset from a (read-only) snapshot of base, mounted
// at mountpoint. base must already have a snapshot named baseSnapshot.
func Clone(ctx context.Context, out io.Writer, base, baseSnapshot, dataset, mountpoint string) error {
- src := fmt.Sprintf("%s@%s", base, baseSnapshot)
- return sh.Run(ctx, out, "", "zfs", "clone", "-o", "mountpoint="+mountpoint, src, dataset)
+ return sh.Run(ctx, out, "", "zfs", "clone", "-o", "mountpoint="+mountpoint, snapRef(base, baseSnapshot), dataset)
}
func Snapshot(ctx context.Context, out io.Writer, dataset, tag string) error {
- return sh.Run(ctx, out, "", "zfs", "snapshot", fmt.Sprintf("%s@%s", dataset, tag))
+ return sh.Run(ctx, out, "", "zfs", "snapshot", snapRef(dataset, tag))
}
// Rollback discards everything written to dataset since the snapshot named
@@ -32,7 +30,7 @@ func Snapshot(ctx context.Context, out io.Writer, dataset, tag string) error {
// used both for the automatic post-health-check-failure rollback and for a
// manual `skiff rollback` days later.
func Rollback(ctx context.Context, out io.Writer, dataset, tag string) error {
- return sh.Run(ctx, out, "", "zfs", "rollback", "-r", fmt.Sprintf("%s@%s", dataset, tag))
+ return sh.Run(ctx, out, "", "zfs", "rollback", "-r", snapRef(dataset, tag))
}
// Snapshots lists snapshot names (without the dataset@ prefix), newest last.