lifecyclehooks

package
v0.127.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package lifecyclehooks runs trusted user-configured commands after WB changes a repository checkout. It is intentionally separate from package hooks, which manages Git's own hook shims and repository policy.

Index

Constants

View Source
const (
	ConfigVersion        = 1
	EventCheckoutUpdated = "checkout-updated"
)

Variables

This section is empty.

Functions

func RepositoryIdentity

func RepositoryIdentity(checkout string) (string, error)

Types

type Binding

type Binding struct {
	On      []string `yaml:"on"`
	Match   Match    `yaml:"match"`
	Execute []string `yaml:"execute"`
}

type Config

type Config struct {
	Version   int                 `yaml:"version"`
	Executors map[string]Executor `yaml:"executors"`
	Bindings  []Binding           `yaml:"bindings"`
}

func Load

func Load(configPath string) (Config, bool, error)

Load reads only the hooks section from the standard wb.yaml. Other WB sections are deliberately ignored while fields inside hooks are strict.

type Dispatcher

type Dispatcher struct {
	ConfigPath   string
	ReceiptPath  string
	Now          func() time.Time
	Run          func(context.Context, Invocation) error
	EvalSymlinks func(string) (string, error)
}

func DefaultDispatcher

func DefaultDispatcher() Dispatcher

func (Dispatcher) Dispatch

func (dispatcher Dispatcher) Dispatch(ctx context.Context, events []Event) (Report, error)

type Event

type Event struct {
	Name        string
	Repository  string
	Checkout    string
	OldSHA      string
	NewSHA      string
	Cause       string
	OperationID string
}

type Executor

type Executor struct {
	Run     string   `yaml:"run"`
	Args    []string `yaml:"args"`
	CWD     string   `yaml:"cwd"`
	Mode    string   `yaml:"mode"`
	Timeout string   `yaml:"timeout"`
	Failure string   `yaml:"failure"`
}

type Invocation

type Invocation struct {
	Executor string
	Run      string
	Args     []string
	Dir      string
	Env      []string
}

type Match

type Match struct {
	Repositories RepositoryMatch `yaml:"repositories"`
}

type Report

type Report struct {
	Executed  int
	Coalesced int
	Warnings  []string
}

func Dispatch

func Dispatch(ctx context.Context, events []Event) (Report, error)

type RepositoryMatch

type RepositoryMatch struct {
	Include []string `yaml:"include"`
	Exclude []string `yaml:"exclude"`
}

Jump to

Keyboard shortcuts

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