Documentation
¶
Overview ¶
Package hooks runs user-defined shell hooks from ~/.ezstack/hooks/.
Exit-code contract:
- pre-* hooks abort the action on non-zero exit (Run returns an error)
- post-* hooks only warn on non-zero exit (callers should log but not fail)
Hooks are never invoked via a shell; the file at ~/.ezstack/hooks/<name> is executed directly, so it must have the executable bit set and include a shebang line if it is a script. Non-existent, non-executable, or directory entries are treated as "no hook installed" (a no-op).
Context is passed via environment variables so hooks can make informed decisions without re-parsing ezstack state:
EZS_HOOK — hook name (e.g. "pre-push") EZS_REPO_ROOT — absolute path to the repo EZS_BRANCH — current branch (if known) EZS_STACK_HASH — current stack hash (if known) EZS_STACK_NAME — current stack name (if set)
Callers build a Context and pass it to Run. Missing fields are simply omitted from the environment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HooksDir ¶
HooksDir returns the absolute path to the hooks directory. It does not create the directory.
Types ¶
type Context ¶
type Context struct {
RepoRoot string
Branch string
StackHash string
StackName string
// Extra lets callers inject additional EZS_* vars without plumbing new
// fields through; keys are used verbatim so callers must include any
// prefix they want.
Extra map[string]string
}
Context carries optional metadata that ezstack exposes to hooks via env vars. All fields are optional; empty fields are not set in the environment.