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
- func AllMembersReady(members []Member) bool
- func AppendTrailer(message string, ref Ref) string
- func CloseCommand(ref Ref) string
- func FormatCloseSummary(ref Ref, members []Member) string
- func FormatStatusLine(u StatusUpdate) string
- func HasExplicitRegistry(raw string) bool
- func NeedsDefaultRegistry(raw string) bool
- func ParseGitHubID(id string) (owner, repo string, number int, err error)
- func ValidateRegistryName(name string) error
- func WithPartOf(body string, link string, ref Ref) string
- type CommandResult
- type GitHubExecutor
- type GitHubProvider
- func (p *GitHubProvider) AppendStatus(ctx context.Context, ref Ref, line string) error
- func (p *GitHubProvider) Close(ctx context.Context, ref Ref, summary string) error
- func (p *GitHubProvider) Registry() string
- func (p *GitHubProvider) RenderLink(ref Ref) (string, error)
- func (p *GitHubProvider) Resolve(ctx context.Context, ref Ref) (Info, error)
- func (p *GitHubProvider) VerifyMembers(ctx context.Context, members []Member) []Member
- type Info
- type Member
- type Provider
- type Ref
- type Registry
- func (r *Registry) AppendStatus(ctx context.Context, ref Ref, line string) error
- func (r *Registry) Close(ctx context.Context, ref Ref, summary string) error
- func (r *Registry) Provider(registry string) (Provider, error)
- func (r *Registry) RenderLink(ref Ref) (string, error)
- func (r *Registry) Resolve(ctx context.Context, ref Ref) (Info, error)
- func (r *Registry) Supported() []string
- func (r *Registry) VerifyMembers(ctx context.Context, ref Ref, members []Member) []Member
- type State
- type StatusUpdate
Constants ¶
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 ¶
AllMembersReady reports whether members is non-empty and every member is verified ready to close.
func AppendTrailer ¶
AppendTrailer adds a "Wb-Umbrella: <registry>:<id>" trailer to a commit message unless the same trailer is already present.
func CloseCommand ¶
CloseCommand returns the exact WB command to close ref with --apply.
func FormatCloseSummary ¶
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 ¶
HasExplicitRegistry reports whether raw includes an explicit "<registry>:" prefix and therefore does not depend on a configured default registry.
func NeedsDefaultRegistry ¶
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 ¶
ParseGitHubID validates a GitHub issue identifier "owner/repo#N".
func ValidateRegistryName ¶
ValidateRegistryName checks that a registry identifier is lowercase ASCII starting with a letter and containing only letters, digits, hyphens, or underscores.
Types ¶
type CommandResult ¶
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 ¶
AppendStatus posts a single-line status comment on the GitHub issue.
func (*GitHubProvider) Registry ¶
func (p *GitHubProvider) Registry() string
Registry returns "github".
func (*GitHubProvider) RenderLink ¶
func (p *GitHubProvider) RenderLink(ref Ref) (string, error)
RenderLink returns GitHub's native cross-repo issue link "owner/repo#N".
func (*GitHubProvider) Resolve ¶
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 ¶
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 ¶
Ref is a typed umbrella reference "<registry>:<id>".
func Parse ¶
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).
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 ¶
NewRegistry builds a provider registry from the given providers.
func (*Registry) AppendStatus ¶
AppendStatus appends one status line to ref through its registered provider.
func (*Registry) Close ¶
Close posts a final summary and closes ref through its registered provider.
func (*Registry) Provider ¶
Provider returns the provider registered for registry, or an exact refusal naming the unsupported registry and the supported registries.
func (*Registry) RenderLink ¶
RenderLink renders the link text for ref through its registered provider.
type State ¶
type State string
State is the open/closed lifecycle state reported by an umbrella provider.
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.