umbrella

package
v0.216.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package umbrella implements registry-agnostic umbrella references (<registry>:<id>), the provider interface, the GitHub provider, and formatting helpers for commit trailers, pull-request body links, status comments, and closing summaries.

Index

Constants

View Source
const (
	// DefaultRegistry is used when an umbrella reference omits "<registry>:"
	// and neither fleet nor repository configuration specifies another registry.
	DefaultRegistry = "github"

	// RegistryGitHub is the built-in GitHub Issues umbrella registry.
	RegistryGitHub = "github"

	// RegistrySynchestra is the planned Synchestra umbrella registry.
	// TODO(sneat-dev/wb#1027): implement the Synchestra umbrella provider in a follow-up issue.
	RegistrySynchestra = "synchestra"

	// TrailerKey is the Git commit trailer key recorded on commits made by WB verbs.
	TrailerKey = "Wb-Umbrella"
)

Variables

This section is empty.

Functions

func AllMembersReady

func AllMembersReady(members []Member) bool

AllMembersReady reports whether members is non-empty and every member is verified ready to close.

func AppendTrailer

func AppendTrailer(message string, ref Ref) string

AppendTrailer adds a "Wb-Umbrella: <registry>:<id>" trailer to a commit message unless the same trailer is already present.

func CloseCommand

func CloseCommand(ref Ref) string

CloseCommand returns the exact WB command to close ref with --apply.

func FormatCloseSummary

func FormatCloseSummary(ref Ref, members []Member) string

FormatCloseSummary builds the final closing summary comment listing every member, its PR, state, landed SHA, and archive restore pointer.

func FormatStatusLine

func FormatStatusLine(u StatusUpdate) string

FormatStatusLine renders a single-line status comment containing repo, PR, outcome, and landed SHA or archive ref. Private text never enters this line. Bare "#N" pull-request labels are qualified with the member repository ("owner/repo#N") so cross-repository umbrella comments link the member PR.

func HasExplicitRegistry

func HasExplicitRegistry(raw string) bool

HasExplicitRegistry reports whether raw includes an explicit "<registry>:" prefix and therefore does not depend on a configured default registry.

func NeedsDefaultRegistry

func NeedsDefaultRegistry(raw string) bool

NeedsDefaultRegistry reports whether parsing raw depends on a configured default registry. Explicit "<registry>:<id>" references and bare GitHub references ("owner/repo#N") resolve without consulting default-registry config.

func ParseGitHubID

func ParseGitHubID(id string) (owner, repo string, number int, err error)

ParseGitHubID validates a GitHub issue identifier "owner/repo#N".

func ValidateRegistryName

func ValidateRegistryName(name string) error

ValidateRegistryName checks that a registry identifier is lowercase ASCII starting with a letter and containing only letters, digits, hyphens, or underscores.

func WithPartOf

func WithPartOf(body string, link string, ref Ref) string

WithPartOf prepends "Part of <link>" to a pull-request body unless a Part of line referencing link or ref is already present.

Types

type CommandResult

type CommandResult struct {
	Stdout []byte
	Stderr []byte
	Err    error
}

CommandResult captures stdout, stderr, and error from one gh invocation.

type GitHubExecutor

type GitHubExecutor func(ctx context.Context, args ...string) CommandResult

GitHubExecutor runs `gh` with args. Nil defaults to running gh through internal/runner, which supplies the fleet's non-interactive child env.

type GitHubProvider

type GitHubProvider struct {
	// contains filtered or unexported fields
}

GitHubProvider implements Provider against GitHub Issues via `gh api`. Every call uses `gh api` so no newer gh subcommand flag is required.

func NewGitHubProvider

func NewGitHubProvider(exec GitHubExecutor) *GitHubProvider

NewGitHubProvider builds a GitHub Issues umbrella provider.

func (*GitHubProvider) AppendStatus

func (p *GitHubProvider) AppendStatus(ctx context.Context, ref Ref, line string) error

AppendStatus posts a single-line status comment on the GitHub issue.

func (*GitHubProvider) Close

func (p *GitHubProvider) Close(ctx context.Context, ref Ref, summary string) error

Close posts the final summary comment and closes the GitHub issue.

func (*GitHubProvider) Registry

func (p *GitHubProvider) Registry() string

Registry returns "github".

func (p *GitHubProvider) RenderLink(ref Ref) (string, error)

RenderLink returns GitHub's native cross-repo issue link "owner/repo#N".

func (*GitHubProvider) Resolve

func (p *GitHubProvider) Resolve(ctx context.Context, ref Ref) (Info, error)

Resolve fetches the issue state from GitHub without retaining title or body.

func (*GitHubProvider) VerifyMembers

func (p *GitHubProvider) VerifyMembers(ctx context.Context, members []Member) []Member

VerifyMembers verifies each member's authoritative remote completion state against GitHub through this provider's gh executor.

type Info

type Info struct {
	Ref   Ref    `json:"ref"`
	State State  `json:"state"`
	Link  string `json:"link"`
}

Info is the provider-resolved metadata for an umbrella reference. It deliberately omits title and body text so private umbrella prose can never leak into public pull requests, commits, or reports.

type Member

type Member struct {
	Task           string    `json:"task"`
	Repository     string    `json:"repository"`
	Branch         string    `json:"branch,omitempty"`
	ClaimID        string    `json:"claim_id,omitempty"`
	HeadSHA        string    `json:"head_sha,omitempty"`
	BaseSHA        string    `json:"base_sha,omitempty"`
	RecordedAt     time.Time `json:"recorded_at,omitempty"`
	PullRequest    int       `json:"pull_request,omitempty"`
	PullRequestURL string    `json:"pull_request_url,omitempty"`
	State          string    `json:"state"`
	LandedSHA      string    `json:"landed_sha,omitempty"`
	ArchiveRef     string    `json:"archive_ref,omitempty"`
	RestorePointer string    `json:"restore_pointer,omitempty"`
	ReadyToClose   bool      `json:"ready_to_close"`
	BlockingReason string    `json:"blocking_reason,omitempty"`
}

Member summarizes one recorded task/repository member of an umbrella.

func VerifyGitHubMembers

func VerifyGitHubMembers(ctx context.Context, exec GitHubExecutor, members []Member) []Member

VerifyGitHubMembers verifies each member with a single containment question answered by GitHub: is the member's final head SHA contained in

  • (a) the repository's default branch, or
  • (b) a remote refs/heads/retired/*, refs/tags/retired/*, or refs/tags/archive/* ref whose name includes the claim's task or branch slug.

Any missing head SHA, gh error, unexpected compare status, or unparsable response refuses the member.

type Provider

type Provider interface {
	Registry() string
	Resolve(ctx context.Context, ref Ref) (Info, error)
	AppendStatus(ctx context.Context, ref Ref, line string) error
	Close(ctx context.Context, ref Ref, summary string) error
	RenderLink(ref Ref) (string, error)
}

Provider plugs an umbrella storage registry into WB.

type Ref

type Ref struct {
	Registry string `json:"registry"`
	ID       string `json:"id"`
}

Ref is a typed umbrella reference "<registry>:<id>".

func Parse

func Parse(raw string, defaultRegistry string) (Ref, error)

Parse parses a typed "<registry>:<id>" reference or a bare "<id>". Bare GitHub-shaped references ("owner/repo#N") always resolve to RegistryGitHub; other bare identifiers use defaultRegistry (or DefaultRegistry when empty).

func (Ref) Display

func (r Ref) Display() string

Display returns the compact human reference: "owner/repo#N" for GitHub and "<registry>:<id>" for other registries.

func (Ref) IsZero

func (r Ref) IsZero() bool

IsZero reports whether the reference is unset.

func (Ref) String

func (r Ref) String() string

String returns the canonical typed reference "<registry>:<id>".

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry routes typed umbrella references to registered providers.

func DefaultProviders

func DefaultProviders(exec GitHubExecutor) *Registry

DefaultProviders constructs the built-in umbrella provider registry. Only the GitHub provider is registered today.

TODO(sneat-dev/wb#1027): register the Synchestra umbrella provider once implemented in its follow-up issue.

func NewRegistry

func NewRegistry(providers ...Provider) *Registry

NewRegistry builds a provider registry from the given providers.

func (*Registry) AppendStatus

func (r *Registry) AppendStatus(ctx context.Context, ref Ref, line string) error

AppendStatus appends one status line to ref through its registered provider.

func (*Registry) Close

func (r *Registry) Close(ctx context.Context, ref Ref, summary string) error

Close posts a final summary and closes ref through its registered provider.

func (*Registry) Provider

func (r *Registry) Provider(registry string) (Provider, error)

Provider returns the provider registered for registry, or an exact refusal naming the unsupported registry and the supported registries.

func (r *Registry) RenderLink(ref Ref) (string, error)

RenderLink renders the link text for ref through its registered provider.

func (*Registry) Resolve

func (r *Registry) Resolve(ctx context.Context, ref Ref) (Info, error)

Resolve resolves and validates ref through its registered provider.

func (*Registry) Supported

func (r *Registry) Supported() []string

Supported returns the sorted list of registered umbrella registry names.

func (*Registry) VerifyMembers

func (r *Registry) VerifyMembers(ctx context.Context, ref Ref, members []Member) []Member

VerifyMembers verifies each member's authoritative remote completion state using the registered provider's GitHub executor when available.

type State

type State string

State is the open/closed lifecycle state reported by an umbrella provider.

const (
	StateOpen   State = "open"
	StateClosed State = "closed"
)

type StatusUpdate

type StatusUpdate struct {
	Task        string
	Repository  string
	PullRequest string // e.g. "#846" or "owner/repo#846"
	Outcome     string // e.g. "landed", "retired", "archived", "aborted (discarded)"
	LandedSHA   string
	ArchiveRef  string
	Note        string
}

StatusUpdate describes one lifecycle status event for an umbrella member.

Jump to

Keyboard shortcuts

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