hooks

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package hooks provides shared pipeline stage hook execution for pipeline, burnish, and quench workers. Hooks are shell commands configured per-anvil that run before or after specific pipeline stages (smith, temper, warden, etc.).

Index

Constants

View Source
const HookTimeout = 60 * time.Second

HookTimeout is the maximum time a single hook command is allowed to run.

Variables

This section is empty.

Functions

func FilterForgeEnv

func FilterForgeEnv(environ []string) []string

FilterForgeEnv returns a copy of environ with any existing FORGE_* variables removed so that hook-specific values are not shadowed or duplicated.

func HookCmd

func HookCmd(hooks *config.HooksConfig, name string) string

HookCmd resolves the command string for a named hook from the anvil config. Returns "" when hooks are not configured or the named hook is not set.

func RunHook

func RunHook(ctx context.Context, workerID, hookName, cmd string, env HookEnv) error

RunHook executes a shell command with the given hook environment. It returns nil when cmd is empty (no hook configured). The command is run via a platform-appropriate shell (sh -c on Unix, cmd /c on Windows) with the worktree as the working directory. A dedicated timeout of HookTimeout is applied to prevent hooks from blocking the pipeline indefinitely.

func ShellArgs

func ShellArgs() (string, string)

ShellArgs returns the platform-appropriate shell and flag for executing a command string. On Windows it uses "cmd /c"; elsewhere "sh -c".

Types

type HookEnv

type HookEnv struct {
	BeadID       string
	WorktreePath string
	Branch       string
	AnvilName    string
	AnvilPath    string
	Stage        string
	Iteration    int
}

HookEnv holds the environment variables passed to pipeline hook commands.

func (HookEnv) Environ

func (h HookEnv) Environ() []string

Environ returns the hook context as a slice of KEY=VALUE strings suitable for appending to exec.Cmd.Env.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL