diff options
| author | Claude <noreply@anthropic.com> | 2026-08-05 23:22:25 -0500 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-08-05 23:22:25 -0500 |
| commit | fc0c6951d7ac36dd8f30ace929991197dc99ae54 (patch) | |
| tree | 46fa11cc103ebe7805bf42bc3e4bb105e6b49721 /internal/layout/layout.go | |
| parent | 9f7c9f2f31acd7bc544dd988af1c8c2fe63ec504 (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/layout/layout.go')
| -rw-r--r-- | internal/layout/layout.go | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/internal/layout/layout.go b/internal/layout/layout.go index 89e6848..636b8ce 100644 --- a/internal/layout/layout.go +++ b/internal/layout/layout.go @@ -55,6 +55,20 @@ func (c Config) NginxConfPath(app string) string { return filepath.Join(c.NginxConfDir, app+".conf") } +func (c Config) PostReceiveHookPath(app string) string { + return filepath.Join(c.RepoPath(app), "hooks", "post-receive") +} + +// RCScriptPath and RCConfPath are paths inside the jail's own chroot, not +// the host's rc.d/rc.conf. +func (c Config) RCScriptPath(app string) string { + return filepath.Join(c.JailRoot(app), "usr", "local", "etc", "rc.d", app) +} + +func (c Config) RCConfPath(app string) string { + return filepath.Join(c.JailRoot(app), "etc", "rc.conf") +} + // Everything below is Capistrano-style: each deploy gets its own immutable // releases/<sha> checkout (built in place, inside the jail's own dataset), // `current` is a symlink to whichever release is live, and data.db/env are @@ -63,8 +77,12 @@ func (c Config) AppDir(app string) string { return filepath.Join(c.JailRoot(app), "app") } +func (c Config) ReleasesDir(app string) string { + return filepath.Join(c.AppDir(app), "releases") +} + func (c Config) ReleaseDir(app, sha string) string { - return filepath.Join(c.AppDir(app), "releases", sha) + return filepath.Join(c.ReleasesDir(app), sha) } func (c Config) CurrentRelease(app string) string { @@ -73,35 +91,14 @@ func (c Config) CurrentRelease(app string) string { // ReleaseDirInJail is releases/<sha> as seen from inside the jail's own // chroot, not the host. The `current` symlink must be written with this -// form as its target: it's dereferenced by the jail's rc.d script (execing -// CurrentBin), where a host-absolute path like ReleaseDir's resolves -// relative to the jail root instead and never exists. +// form as its target: it's dereferenced by the jail's rc.d script (which +// execs /app/current/app, per internal/tmpl/rc.d.tmpl's command_args), +// where a host-absolute path like ReleaseDir's resolves relative to the +// jail root instead and never exists. func (c Config) ReleaseDirInJail(sha string) string { return filepath.Join("/app", "releases", sha) } -// CurrentBin is the path the jail's rc.d script execs - must match -// internal/tmpl/rc.d.tmpl's command_args. -func (c Config) CurrentBin(app string) string { - return filepath.Join(c.CurrentRelease(app), "app") -} - -func (c Config) MakefilePath(app, sha string) string { - return filepath.Join(c.ReleaseDir(app, sha), "Makefile") -} - -func (c Config) DataDB(app string) string { - return filepath.Join(c.AppDir(app), "data.db") -} - -func (c Config) EnvFile(app string) string { - return filepath.Join(c.AppDir(app), "env") -} - func (c Config) MetaPath(app string) string { return filepath.Join(c.AppDir(app), "meta.json") } - -func (c Config) SnapshotName(app, sha string) string { - return fmt.Sprintf("%s@pre-%s", c.AppDataset(app), sha) -} |
