Documentation
¶
Overview ¶
Package officership is what lets an officer SHIP: push branches, merge its own pull requests and tag releases in one repository, with every write decided in muster-server (docs/officers.md "Shipping officers").
- pushgate.go: the connector-proxy write filter (a connectors.Gate) an instance's every GitHub request passes through;
- gates.go: officer_merge_pr's and officer_tag_release's gates, all read fresh from GitHub and HQ at call time;
- lint.go: the destructive-DDL lint on migration files;
- rollout.go: the post-release watch and the automatic rollback.
🔴 THE REPOSITORY ENFORCES NOTHING, SO THIS PACKAGE IS THE BRANCH PROTECTION. A private repository on a plan without branch protection or rulesets lets any `contents: write` token push to its base branch, push any tag and merge with red checks. The officer's write token therefore never leaves muster: the instance's requests reach GitHub only through the push gate, and merges and tags are made here, after the gates, with muster's own token.
Index ¶
- Constants
- Variables
- func BotLogin(slug string) string
- func Excerpt(log string, maxBytes int) (string, bool)
- func IsRollbackTag(message string) bool
- func NewKubeCIOpener(ns, sa string) (func(ctx context.Context) (CIReader, error), error)
- func Redact(line string) string
- func RedactCutTail(s string, known []string) string
- func RedactLines(lines []string) []string
- func RedactText(s string) string
- func SensitiveFiles(patterns []string, files []File) []string
- type CILogsOutcome
- type CILogsReader
- type CIReader
- type CheckRun
- type Comment
- type Compare
- type File
- type Finding
- type Gates
- type GitHub
- type HQ
- type MergeOutcome
- type PR
- type PipelineRun
- type PushGate
- func (g *PushGate) Admit(r *http.Request, host, rest string) (*http.Request, error)
- func (g *PushGate) Connector() string
- func (g *PushGate) Credential(ctx context.Context, caller connectors.Caller, host, rest string) (string, bool, error)
- func (g *PushGate) Describe() connectors.Connector
- func (g *PushGate) Rejected(caller connectors.Caller)
- type REST
- func (g *REST) AppSlug(ctx context.Context) (string, error)
- func (g *REST) BranchSHA(ctx context.Context, branch string) (string, error)
- func (g *REST) CheckRuns(ctx context.Context, sha, name string) ([]CheckRun, error)
- func (g *REST) Commit(ctx context.Context, sha string) (string, []string, error)
- func (g *REST) Compare(ctx context.Context, base, head string) (Compare, error)
- func (g *REST) CreateCommit(ctx context.Context, message, tree string, parents []string) (string, error)
- func (g *REST) CreateRef(ctx context.Context, ref, sha string) error
- func (g *REST) CreateTag(ctx context.Context, name, message, sha string, t Tagger) (string, error)
- func (g *REST) FileAt(ctx context.Context, path, ref string) ([]byte, error)
- func (g *REST) MarkReady(ctx context.Context, n int, nodeID string) error
- func (g *REST) Merge(ctx context.Context, n int, sha string) (string, error)
- func (g *REST) MergeInto(ctx context.Context, base, head, message string) (string, error)
- func (g *REST) OpenPR(ctx context.Context, title, head, base, body string) (int, error)
- func (g *REST) PR(ctx context.Context, n int) (PR, error)
- func (g *REST) PRComments(ctx context.Context, n int) ([]Comment, error)
- func (g *REST) PRFiles(ctx context.Context, n int) ([]File, error)
- func (g *REST) PRsForCommit(ctx context.Context, sha string) ([]PR, error)
- func (g *REST) Statuses(ctx context.Context, sha string) (map[string]string, error)
- func (g *REST) TagObject(ctx context.Context, sha string) (TagObject, error)
- func (g *REST) Tags(ctx context.Context) ([]TagRef, error)
- type ReadyOutcome
- type Refusal
- type Step
- type TagObject
- type TagOptions
- type TagOutcome
- type TagRef
- type Tagger
- type TaskFailure
- type TaskRun
- type Version
- type WatchStatus
- type Watcher
- func (w *Watcher) InFlight() (string, bool)
- func (w *Watcher) LiveVersion(ctx context.Context) (string, error)
- func (w *Watcher) Resume(ctx context.Context)
- func (w *Watcher) Start(ctx context.Context, rel TagOutcome, itemID string) error
- func (w *Watcher) Status() (cur *WatchStatus, history []WatchStatus)
- func (w *Watcher) Wait()
Constants ¶
const ( CIStateNoRun = "no_run" CIStateRunning = "running" CIStateSucceeded = "succeeded" CIStateFailed = "failed" )
CIRunState is a PipelineRun's state as officer_ci_logs reports it.
const ( GateStage = "stage" GateHQEnabled = "hq_enabled" GatePR = "pull_request" GateBase = "base" GateHeadBranch = "head_branch" GateAuthor = "author" GateMergeable = "mergeable" GateUpToDate = "up_to_date" GateChecks = "checks" GateReview = "review" GateHold = "hold" GateMigrations = "migrations" GateNotice = "notice" GateMerge = "merge" // GateReady is officer_mark_ready's write: GitHub's draft -> ready // conversion. GateReady = "ready" GateTags = "tags" GateAncestor = "ancestor" GateInFlight = "in_flight" GateRate = "rate" GateQuietHours = "quiet_hours" GateMainCI = "main_ci" GateBackup = "backup" GateTagCreate = "tag_create" // GateUntestedMerge refuses a release while the base's head is an // officer merge that raced the base (MergeOutcome.UntestedTree). GateUntestedMerge = "untested_merge" )
Gate names, as a refusal and the call log name them.
const ( VerdictWatching = "watching" VerdictHealthy = "healthy" VerdictNotLive = "not_live" VerdictUnhealthy = "unhealthy" VerdictSuperseded = "superseded" VerdictAborted = "aborted" )
Watch verdicts.
const GateCIRuns = "ci_runs"
GateCIRuns is officer_ci_logs's cluster gate (besides GatePR, GateHeadBranch, GateAuthor).
Variables ¶
var ErrMergeConflict = errors.New("officership: merge conflict")
ErrMergeConflict is a merge GitHub could not make cleanly (409).
var ErrRefExists = errors.New("officership: the ref already exists")
ErrRefExists is a create of a ref that already exists (GitHub's 422): the compare-and-swap against a concurrent tag or branch.
Functions ¶
func Excerpt ¶ added in v0.125.0
Excerpt reduces a CI log to what explains its failure — the failing-test and error lines (deduplicated, in order, repeats counted), then the log's last lines — every line passed through RedactLines and cut at maxExcerptLine bytes, the whole at most maxBytes bytes (never splitting a character). cut reports that the cap dropped something or an emitted line was clipped.
func IsRollbackTag ¶
IsRollbackTag reports whether an annotated tag's message carries the rollback trailer (a whole line, exactly).
func NewKubeCIOpener ¶ added in v0.125.0
NewKubeCIOpener builds the production CILogsReader.Open for the CI namespace ns: each call mints a 600 s token for ServiceAccount sa in muster's OWN namespace (TokenRequest, with muster's own in-cluster identity, which may create serviceaccounts/token for sa only) and returns a reader authenticated by that token alone.
🔴 muster's own token MINTS; it never READS. The reader's config is built fresh (ciReaderConfig), so nothing of muster's credentials — its token file above all, which client-go would prefer over the minted token — reaches it.
func Redact ¶ added in v0.125.0
Redact is the one-line filter (RedactLines applies it to every line outside a PEM block): a line that looks like it carries a credential, or is an environment assignment, is withheld whole; a URL's userinfo is masked.
func RedactCutTail ¶ added in v0.127.0
RedactCutTail withholds every line in which a word cut by a cap — the word right before a cutMark — could be a credential's prefix: it starts like a known token shape (cutPrefixRE), or it ends in the first 4 or more bytes of one of known (a credential the caller holds and can name). A shape pattern needs the whole token; a cap can leave only its start, and that start is still the credential's.
func RedactLines ¶ added in v0.125.0
RedactLines is THE secret filter of a CI log, line by line WITH STATE: a PEM block is withheld whole, from its BEGIN line through its END line (to the end of the log when END never came — a step that died mid-print); every other line goes through Redact, and a bare long base64 line is withheld.
func RedactText ¶ added in v0.127.0
RedactText is THE CI-log secret filter (RedactLines, unchanged) over any multi-line text — an officer's session transcript forwarded to HQ (internal/officers/transcript) — split at the same separators as a log (\n, \r\n, a lone \r) but KEEPING empty lines, so prose keeps its paragraphs. Every line is joined back with \n.
func SensitiveFiles ¶
SensitiveFiles are the changed paths (a rename's old path included) that match any pattern, sorted and unique.
Types ¶
type CILogsOutcome ¶ added in v0.125.0
type CILogsOutcome struct {
PR int `json:"pr"`
HeadSHA string `json:"head_sha"`
// PipelineRun is the run read (the newest for the head); OtherRuns is how
// many older runs for the same head were ignored.
PipelineRun string `json:"pipeline_run,omitempty"`
OtherRuns int `json:"other_runs_for_this_head,omitempty"`
State string `json:"state"`
RunMessage string `json:"run_message,omitempty"`
// Failed are the failed tasks, each with its excerpt.
Failed []TaskFailure `json:"failed_tasks"`
// Note says, in words, what was found — never empty.
Note string `json:"note"`
}
CILogsOutcome is officer_ci_logs's answer.
type CILogsReader ¶ added in v0.125.0
type CILogsReader struct {
Repo string
Ship *officers.Ship
Config *officers.CILogs
GH GitHub
// Open returns a reader for ONE call — in production with a freshly
// minted token ([NewKubeCIOpener]). It is called only once ownership
// passed, and at most once per call.
Open func(ctx context.Context) (CIReader, error)
}
CILogsReader answers officer_ci_logs for one officer. Its caller (internal/api) builds it only for an officer with a ship and ci_logs block.
func (*CILogsReader) Read ¶ added in v0.125.0
func (r *CILogsReader) Read(ctx context.Context, n int) (CILogsOutcome, error)
Read answers officer_ci_logs{pr}.
type CIReader ¶ added in v0.125.0
type CIReader interface {
// PipelineRuns lists the PipelineRuns matching a label selector.
PipelineRuns(ctx context.Context, selector string) ([]PipelineRun, error)
// TaskRuns lists the TaskRuns of one PipelineRun.
TaskRuns(ctx context.Context, pipelineRun string) ([]TaskRun, error)
// PodLog reads the END of one container's log: at most its last
// maxBytes bytes (and last tailLogLines lines); cut reports that anything
// before that was dropped.
PodLog(ctx context.Context, pod, container string, maxBytes int64) (log string, cut bool, err error)
}
CIReader is every cluster read officer_ci_logs makes, in ONE namespace (the implementation is bound to it). The production one is [NewKubeCIReader]; the tests use a fake.
type Comment ¶
Comment is any human-or-bot text on a pull request: a conversation comment, a review body or a review comment.
type Compare ¶
type Compare struct {
Status string // ahead | behind | diverged | identical
AheadBy int
BehindBy int
Files []File
Commits []string // shas, oldest first
}
Compare is GET compare/{base}...{head}.
type File ¶
type File struct {
Path string
Previous string // a rename's old path
Status string // added | modified | removed | renamed | copied | changed | unchanged
}
File is one changed file of a pull request or a comparison.
type Finding ¶
Finding is one destructive statement in a migration file.
func LintMigration ¶
LintMigration returns every destructive statement in one migration file. An empty result is a pass.
type Gates ¶
type Gates struct {
OfficerID string
Repo string
Ship *officers.Ship
GH GitHub
HQ HQ
Now func() time.Time
// InFlight reports a release the rollout watch still owns (its tag).
InFlight func() (string, bool)
// LiveVersion reads the version the service reports now (the rollout's
// health URL).
LiveVersion func(ctx context.Context) (string, error)
// contains filtered or unexported fields
}
Gates are officer_merge_pr's and officer_tag_release's checks for one officer. Every input is read from GitHub and HQ at call time; nothing is cached between calls.
func (*Gates) MarkReady ¶ added in v0.123.0
MarkReady converts the officer's own DRAFT pull request n to ready for review — the one draft transition an officer may make. A shipping officer opens test-first pull requests as drafts (the red-before commit must not look reviewable); once CI is green it marks the pull request ready so the review check runs, which officer_merge_pr then requires.
The gates, in order, read fresh:
- pull_request — open, not merged, and a draft (an already-ready one is refused: there is no ready -> draft here, and no no-op write);
- base / head_branch / author — the officer's own ([Gates.ownPR]);
- ready — GitHub's GraphQL markPullRequestReadyForReview on the node id read in 1.
No stage gate (a shadow officer's pull requests are reviewed too) and no HQ gate: this is an edit of the officer's own pull request, which the push gate already forwards (title, body, state) without either. GitHub's REST PATCH pulls takes no `draft` field, which is why this is a tool and not a push-gate rule.
func (*Gates) MergePR ¶
MergePR squash-merges the officer's own pull request n if, and only if, every merge gate passes now. A refusal is a *Refusal naming the gate; on a refusal nothing was written (a sensitive-path notice may have been posted only when every OTHER gate had passed).
The gates, in order:
- stage — the officer's stage allows merging;
- hq_enabled — HQ answers and says the officer is enabled (fail closed);
- base / head_branch / author — open, not draft, into the base branch, from <prefix>… in the same repository, authored by the officer App's bot;
- mergeable — GitHub says mergeable (unknown is "call again");
- up_to_date — the head contains the base's head (behind_by 0);
- checks — every required check is success on the head commit (a commit status, or a completed check run);
- review — the newest review check run on the head is completed+success (neutral fails; from review_app when set);
- hold — no human wrote /hold on the pull request;
- migrations — no destructive DDL in an added or changed migration, and no migration removed or renamed;
- notice — if a sensitive path changed, HQ accepted the notice;
- merge — GitHub squash-merges with the head pinned to the checked sha.
func (*Gates) TagRelease ¶
func (g *Gates) TagRelease(ctx context.Context, opt TagOptions) (TagOutcome, error)
TagRelease creates the next minor release tag (annotated) on the base branch's head if, and only if, every release gate passes now:
- stage — the officer's stage allows releasing;
- hq_enabled — HQ says the officer is enabled (fail closed);
- tags / ancestor — the highest vX.Y.Z tag T is an ancestor of the base's head H, and H is ahead of it (else nothing to release);
- in_flight — no release the rollout watch still owns, and the service reports T's version (the previous release is live);
- rate — fewer than releases_per_day officer tags in the last 24 h, and none in the last min_release_gap;
- quiet_hours — not inside them;
- main_ci — the required checks are success for H's exact tree;
- migrations / backup — no destructive DDL in a migration added in T..H, and, when one was added, HQ's backup preflight passes;
- tag_create — GitHub creates refs/tags/<next>; a tag pushed by someone else first makes this fail, and the tool reports it.
type GitHub ¶
type GitHub interface {
AppSlug(ctx context.Context) (string, error)
PR(ctx context.Context, n int) (PR, error)
PRFiles(ctx context.Context, n int) ([]File, error)
Compare(ctx context.Context, base, head string) (Compare, error)
// Statuses is the latest commit status per context on sha.
Statuses(ctx context.Context, sha string) (map[string]string, error)
CheckRuns(ctx context.Context, sha, name string) ([]CheckRun, error)
PRComments(ctx context.Context, n int) ([]Comment, error)
FileAt(ctx context.Context, path, ref string) ([]byte, error)
BranchSHA(ctx context.Context, branch string) (string, error)
Tags(ctx context.Context) ([]TagRef, error)
TagObject(ctx context.Context, sha string) (TagObject, error)
// Commit is a commit's tree and parents.
Commit(ctx context.Context, sha string) (tree string, parents []string, err error)
PRsForCommit(ctx context.Context, sha string) ([]PR, error)
Merge(ctx context.Context, n int, sha string) (string, error)
CreateTag(ctx context.Context, name, message, sha string, t Tagger) (string, error)
CreateRef(ctx context.Context, ref, sha string) error
CreateCommit(ctx context.Context, message, tree string, parents []string) (string, error)
MergeInto(ctx context.Context, base, head, message string) (string, error)
OpenPR(ctx context.Context, title, head, base, body string) (int, error)
// MarkReady converts draft pull request n (GraphQL node nodeID) to ready
// for review. 🔴 REST cannot: PATCH pulls takes no `draft` field (only
// POST pulls does), so this is the GraphQL markPullRequestReadyForReview
// mutation, and it errs unless GitHub answers pull request n, not a draft.
MarkReady(ctx context.Context, n int, nodeID string) error
}
GitHub is every GitHub read and write the gates and the watcher make, for ONE repository. The REST implementation is REST; the tests use a fake.
type HQ ¶
type HQ interface {
// Enabled is HQ's on/off switch for the officer (GET /officers/{id}).
Enabled(ctx context.Context) (bool, error)
// PostNotice posts the sensitive-path notice (POST to path under hq_url).
PostNotice(ctx context.Context, path string, n officers.Notice) error
// Preflight is HQ's database backup health (POST /officers/{id}/preflight).
Preflight(ctx context.Context) (officers.Preflight, error)
}
HQ is what the gates ask HQ, with the officer's own token.
type MergeOutcome ¶
type MergeOutcome struct {
PR int `json:"pr"`
HeadSHA string `json:"head_sha"`
MergeSHA string `json:"merge_sha"`
Passed []string `json:"gates_passed"`
Noticed []string `json:"sensitive_paths_noticed,omitempty"`
// UntestedTree: the merge landed on a base that moved after the gates
// read it, so the base now holds a tree no CI run saw (Warning says so).
UntestedTree bool `json:"untested_tree,omitempty"`
Warning string `json:"warning,omitempty"`
}
MergeOutcome is what officer_merge_pr did.
type PR ¶
type PR struct {
Number int
NodeID string // the GraphQL id (officer_mark_ready's mutation names it)
State string
Draft bool
Merged bool
Mergeable *bool
Author string
AuthorType string
HeadRef string
HeadSHA string
HeadRepo string
BaseRef string
BaseRepo string
Title string
MergeCommitSHA string
}
PR is the part of a pull request the gates read.
type PipelineRun ¶ added in v0.125.0
type PipelineRun struct {
Name string
Created time.Time
Labels map[string]string
Params map[string]string
// Succeeded is the Succeeded condition's status: True, False or Unknown
// ("" when there is none yet).
Succeeded string
Reason string
Message string
}
PipelineRun is the part of a Tekton PipelineRun officer_ci_logs reads.
func ParsePipelineRun ¶ added in v0.125.0
func ParsePipelineRun(obj map[string]any) PipelineRun
ParsePipelineRun reads a tekton.dev/v1 PipelineRun object.
type PushGate ¶
type PushGate struct {
// Repo is the officer's repository (owner/name).
Repo string
// Ship is the officer's policy (Base, BranchPrefix).
Ship *officers.Ship
// GitHost and APIHost are the hosts served (github.com, api.github.com).
GitHost, APIHost string
// Cred mints the credential for an admitted request (the officer App's
// connectors.Virtual Credential: its token for Repo, anonymous elsewhere).
Cred func(ctx context.Context, caller connectors.Caller, host, rest string) (string, bool, error)
// OnRejected drops a cached credential after a 401.
OnRejected func(caller connectors.Caller)
// GH reads a pull request (PATCH's own-PR check) and the App's slug.
GH GitHub
}
PushGate is a shipping officer's connectors.Gate: the write filter every one of its instance's GitHub requests passes through in muster's connector proxy, and the source of the (write-capable) credential an admitted request carries.
🔴 IT IS AN ALLOWLIST. A read (GET, HEAD) is forwarded. A write is forwarded only when it is one of these, in the officer's own repository:
- git push (POST …/git-receive-pack) whose EVERY ref update targets refs/heads/<prefix>… — so never the base branch, never a tag;
- git fetch (POST …/git-upload-pack), which writes nothing;
- POST /repos/{repo}/pulls with head <prefix>… and base = the base branch;
- PATCH /repos/{repo}/pulls/{n} of the officer's OWN pull request (its App's bot authored it, its head is <prefix>…), title/body/state only — never `draft`, which REST PATCH does not take: draft -> ready is the officer_mark_ready tool (GraphQL, after the same own-PR gates);
- POST /repos/{repo}/issues/{n}/comments on its OWN pull request.
Every other method, path and host shape is refused — the merge endpoint, the git/refs and git/tags endpoints, releases, the contents API (which commits to any branch), the merges API, GraphQL (which can do all of those), and every DELETE. Merges and tags are made by officer_merge_pr and officer_tag_release in muster-server, after their gates.
func (*PushGate) Credential ¶
func (g *PushGate) Credential(ctx context.Context, caller connectors.Caller, host, rest string) (string, bool, error)
Credential implements connectors.Gate.
func (*PushGate) Describe ¶
func (g *PushGate) Describe() connectors.Connector
Describe implements connectors.Gate: the GitHub preset's shape.
func (*PushGate) Rejected ¶
func (g *PushGate) Rejected(caller connectors.Caller)
Rejected implements connectors.Gate.
type REST ¶
type REST struct {
Base string // API base, no trailing slash
Repo string // owner/name
Token func(ctx context.Context) (string, error)
// Slug reads the App's slug (GET /app, as the App).
Slug func(ctx context.Context) (string, error)
HTTP *http.Client
}
REST is GitHub over GitHub's REST API for Repo, authenticated by Token (the officer App's installation token, minted per call by muster).
func (*REST) Compare ¶
Compare implements GitHub. 🔴 GitHub lists at most 300 files and 250 commits in one comparison; a comparison at either cap is refused rather than read as complete.
func (*REST) CreateCommit ¶
func (g *REST) CreateCommit(ctx context.Context, message, tree string, parents []string) (string, error)
CreateCommit implements GitHub.
func (*REST) Merge ¶
Merge implements GitHub: a squash merge that GitHub refuses (409) unless the head is still sha — the match-head-commit guard.
func (*REST) MergeInto ¶
MergeInto implements GitHub (POST merges: head merged into branch base). A conflict is ErrMergeConflict.
func (*REST) PRComments ¶
PRComments implements GitHub: conversation comments, review bodies and review comments, every page.
func (*REST) PRsForCommit ¶
PRsForCommit implements GitHub.
type ReadyOutcome ¶ added in v0.123.0
type ReadyOutcome struct {
PR int `json:"pr"`
Ready bool `json:"ready"`
Passed []string `json:"gates_passed"`
}
ReadyOutcome is what officer_mark_ready did.
type Refusal ¶
Refusal is a gate that did not pass. Nothing was written.
type Step ¶ added in v0.125.0
type Step struct {
Name string
Container string
// Terminated is false while the step has not ended.
Terminated bool
ExitCode int
Reason string
}
Step is one step of a TaskRun: its container and how it ended.
type TagObject ¶
type TagObject struct {
SHA string
Tagger string
TaggedAt time.Time
TargetSHA string
TargetType string
Message string
}
TagObject is an annotated tag.
type TagOptions ¶
type TagOptions struct {
// Rollback is the rollout watch's own release of a revert: it skips the
// in-flight, rate, quiet-hours and HQ-enabled gates (the release being
// rolled back is the one in flight, and HQ may be what is down) and keeps
// every other.
Rollback bool
}
TagOptions are officer_tag_release's inputs.
type TagOutcome ¶
type TagOutcome struct {
Tag string `json:"tag"`
SHA string `json:"sha"`
Previous string `json:"previous"`
PreviousSHA string `json:"previous_sha"`
TaggedAt time.Time `json:"tagged_at"`
Passed []string `json:"gates_passed"`
Migrations []string `json:"migrations,omitempty"`
}
TagOutcome is what officer_tag_release did.
type TagRef ¶
type TagRef struct {
Name string
ObjectSHA string
ObjectType string // commit (lightweight) | tag (annotated)
}
TagRef is one refs/tags/* ref: its name and the object it points at.
type TaskFailure ¶ added in v0.125.0
type TaskFailure struct {
Task string `json:"task"`
TaskRun string `json:"task_run"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
FailedSteps []string `json:"failed_steps,omitempty"`
Excerpt string `json:"excerpt"`
// Truncated: something was cut — a log read dropped the log's start, an
// excerpt hit its byte share, or a line in it was clipped.
Truncated bool `json:"truncated,omitempty"`
// LogErrors are logs that could not be read (the pod pruned, …).
LogErrors []string `json:"log_errors,omitempty"`
}
TaskFailure is one failed TaskRun.
type TaskRun ¶ added in v0.125.0
type TaskRun struct {
Name string
// PipelineRun is the TaskRun's tekton.dev/pipelineRun label.
PipelineRun string
PipelineTask string
PodName string
Succeeded string
Reason string
Message string
Steps []Step
}
TaskRun is the part of a Tekton TaskRun officer_ci_logs reads.
func ParseTaskRun ¶ added in v0.125.0
ParseTaskRun reads a tekton.dev/v1 TaskRun object.
type Version ¶
type Version struct{ Major, Minor, Patch int }
Version is a vMAJOR.MINOR.PATCH tag.
func ParseVersion ¶
ParseVersion reads a release tag; ok is false for anything else.
type WatchStatus ¶
type WatchStatus struct {
Tag string `json:"tag"`
SHA string `json:"sha"`
Previous string `json:"previous"`
ItemID string `json:"item_id,omitempty"`
TaggedAt time.Time `json:"tagged_at"`
Phase string `json:"phase"`
Verdict string `json:"verdict"`
LiveAt time.Time `json:"live_at,omitempty"`
RevertPR int `json:"revert_pr,omitempty"`
RollbackTag string `json:"rollback_tag,omitempty"`
Escalated bool `json:"escalated"`
// Rollback is true for the watch of a ROLLBACK release: it is never itself
// rolled back.
Rollback bool `json:"rollback"`
Events []string `json:"events"`
Done bool `json:"done"`
}
WatchStatus is one release's watch, as officer_rollout_status reports it.
type Watcher ¶
type Watcher struct {
OfficerID string
Repo string
Ship *officers.Ship
GH GitHub
Gates *Gates
HTTP *http.Client
Now func() time.Time
// Sleep waits d or until ctx ends (tests replace it).
Sleep func(ctx context.Context, d time.Duration) error
Logf func(format string, args ...any)
// contains filtered or unexported fields
}
Watcher watches one officer's releases, one at a time.
func (*Watcher) LiveVersion ¶
LiveVersion is the version the service reports now (Gates.LiveVersion).
func (*Watcher) Resume ¶
Resume restarts the watch of the newest release after a muster restart, when that release is the officer's own and still inside its watch window. A restart therefore costs at most the probes it missed, not the watch.
func (*Watcher) Start ¶
Start begins watching a release in the background (ctx ends it). A watch already in flight is refused: officer_tag_release's in-flight gate makes that unreachable except by a rollback, which watches inline.
func (*Watcher) Status ¶
func (w *Watcher) Status() (cur *WatchStatus, history []WatchStatus)
Status is the current (or last) watch and the earlier ones of this process.