hooks

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package hooks is the Go port of .lok8s/libs/hooks — dev-time lifecycle actions on rendered artifacts, selected by label.

INTERNAL: driven by the Tilt `hooks:` wrapper (a local_resource cmd), not a user workflow. Acts on the live cluster + the domain's rendered artifacts to re-run/refresh a LABELLED subset when a watched file changes:

recreate — delete + apply the matched objects (immutable Jobs re-run)
restart  — rollout restart the matched workloads
apply    — re-apply the matched objects (no delete)

Targeting is by LABEL — the same labels lok8s applies — passed kubectl-style: lo hooks recreate --selector lok8s.dev/type=seed,… The selector validation and the label filter are native (the bash built a yq `select(...)` expression; the ACCEPTED grammar and error strings are identical); kubectl and the tilt probes run through the Runner seam.

Index

Constants

This section is empty.

Variables

View Source
var ErrHandled = ui.ErrHandled // one sentinel for every package; see internal/ui

ErrHandled marks a failure whose message was already printed in the bash [error] format; callers exit non-zero without printing anything further.

Functions

This section is empty.

Types

type Context

type Context struct {
	Paths  *config.Paths
	Runner execx.Runner
	Out    io.Writer
	ErrOut io.Writer
	// Domain is the parent's resolved global arg (bash: consumed via
	// :^~domain), so the Tilt wrapper never has to pass it.
	Domain string

	// Tilt answers the session probes (Running/HasResource/
	// TriggerResource). nil → a Context over the same Runner.
	Tilt *tilt.Context
	// Applier runs the kapply::apply port. nil → kapply.NewApplier.
	Applier *kapply.Applier
}

Context carries one hooks-command invocation. LOK8S_NONINTERACTIVE=1 is exported by the command layer before anything runs (bash: main::hooks) — Tilt's local_resource has no controlling terminal, so kapply must never try the /dev/tty progress UI or confirm prompts.

func (*Context) Apply

func (c *Context) Apply(ctx context.Context, selector string) error

Apply re-applies the selected objects, no delete (bash: hooks::apply).

func (*Context) Recreate

func (c *Context) Recreate(ctx context.Context, selector string) error

Recreate deletes + applies the selected objects so immutable Jobs re-run (bash: hooks::recreate).

func (*Context) Restart

func (c *Context) Restart(ctx context.Context, selector string) error

Restart rollout-restarts the selected workloads (bash: hooks::restart).

Jump to

Keyboard shortcuts

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