recipe

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package recipe implements wb's config-driven fleet operations: a Recipe describes how to detect and mutate matching repos, and how to land the result via the same worktree/commit/push-or-PR flow used everywhere else in wb.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Land

func Land(r Recipe, repoPath, defaultBranch string) (gitops.Outcome, error)

Land applies r to repoPath and lands the result via git (direct push, or an auto-merge PR when the branch is protected or the local clone is dirty) — reusing gitops.Land. err is non-nil only for a hard failure (unreadable template, a git/gh command failing); "nothing changed" is a normal, successful Outcome with Changed=false.

Types

type Action

type Action int

Action describes what a template-section recipe did (or would do) to its target file.

const (
	ActionNoop Action = iota
	ActionInsert
	ActionReplace
)

func (Action) String

func (a Action) String() string

type Config

type Config struct {
	Recipes map[string]Recipe `yaml:"recipes"`
}

Config is the parsed wb.yaml.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads, parses, and validates the recipe config at path.

type Kind

type Kind string

Kind is a recipe's mutation strategy.

const (
	KindTemplateSection Kind = "template-section"
	KindCommand         Kind = "command"
)

type Preview

type Preview struct {
	Summary string
	Changed bool
}

Preview is what dry-run mode reports for one repo.

func Evaluate

func Evaluate(r Recipe, repoPath string) (Preview, error)

Evaluate previews what r would do to repoPath without mutating anything.

For a template-section recipe, this fetches and inspects the target file at origin/<default-branch> — matching what Land will actually work from (a fresh worktree off the default branch), not any local uncommitted state. For a command recipe, DryRunCommand (if set) runs directly against repoPath's current local working tree, mirroring how a linter is normally invoked.

type Recipe

type Recipe struct {
	Name string `yaml:"-"` // set from the config map key, not the YAML body

	Type      Kind   `yaml:"type"`
	AppliesIf string `yaml:"applies_if"`

	// template-section fields
	Target   string `yaml:"target"`
	Template string `yaml:"template"`
	Marker   string `yaml:"marker"`

	// command fields
	Command       string `yaml:"command"`
	DryRunCommand string `yaml:"dry_run_command"`
	CountRegex    string `yaml:"count_regex"`

	// landing fields (shared, all optional — defaulted from Name)
	CommitMessage string `yaml:"commit_message"`
	PRBranch      string `yaml:"pr_branch"`
	PRTitle       string `yaml:"pr_title"`
	PRBody        string `yaml:"pr_body"`
}

Recipe describes one fleet-wide operation, as configured in wb.yaml.

func (Recipe) AppliesTo

func (r Recipe) AppliesTo(repoPath string) (bool, error)

AppliesTo evaluates r.AppliesIf against repoPath.

Jump to

Keyboard shortcuts

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