Documentation
¶
Overview ¶
Package action owns the human-action vocabulary and the state-machine gating behind it: which verbs exist, and what each one is allowed to do to a Finding's spec in a given phase.
It exists so the two clients that apply human actions cannot drift. The status server (internal/web) applies them as its own ServiceAccount after a SubjectAccessReview; the patchy CLI (cmd/patchy) applies them as the signed-in user's kubeconfig identity. Both call Apply, so a phase gate tightened here tightens in both places at once.
Authorization is NOT this package's job. It decides only whether an action is meaningful, never whether the caller may take it. Grants live in internal/web/authz (SubjectAccessReview) for the server, in a SelfSubjectAccessReview for the CLI, and are enforced for real by the ValidatingAdmissionPolicy that binds each custom verb to the spec field it governs.
Every verb is idempotent: re-applying one whose effect is already recorded succeeds and reports changed=false, so a double-click and a re-run of a shell loop both degrade to no-ops rather than churning the object.
Index ¶
Constants ¶
const ( // VerbApprove releases the breaking-change hold and revives handed-off // findings. VerbApprove = "approve" // VerbRetry recovers a Failed finding to the state it failed from. VerbRetry = "retry" // VerbExpedite skips the waiting stages: the accumulation window, the // minimum age, and queue position. VerbExpedite = "expedite" // VerbSuspend pauses pipeline progress for a finding. VerbSuspend = "suspend" // VerbResume lifts a suspension. VerbResume = "resume" // VerbBackfill lists an integration's pre-existing open alerts (the ones // that predate webhook coverage) into findings. Integration-scoped. VerbBackfill = "backfill" // VerbReplay redelivers the webhook delivery log (integration-scoped // demo tooling). VerbReplay = "replay" // VerbReset deletes every pipeline resource in the namespace // (integration-scoped demo tooling). VerbReset = "reset" )
Verbs the human-action surface understands. They are custom RBAC verbs: the per-finding ones on findings.patchy.bitwisemedia.uk, the integration-scoped ones on integrations.patchy.bitwisemedia.uk. The API server treats them as plain strings, so granting one confers exactly one action.
Variables ¶
var ( // state has no use for it. ErrUnavailable = errors.New("action is not available in this phase") // ErrUnknownVerb reports a verb outside ActionVerbs. ErrUnknownVerb = errors.New("unknown action verb") )
Errors Apply returns. Callers map them onto their own vocabulary: the status server turns ErrUnavailable into a 403 and ErrUnknownVerb into a 404; the CLI turns them into exit codes.
var ActionVerbs = []string{VerbApprove, VerbRetry, VerbExpedite, VerbSuspend, VerbResume}
ActionVerbs lists the per-finding verbs in the order clients present them.
var AdminVerbs = []string{VerbReplay, VerbReset}
AdminVerbs lists the demo-tooling verbs the status page's user menu surfaces, resolved on integrations.
var IntegrationVerbs = []string{VerbBackfill, VerbReplay, VerbReset}
IntegrationVerbs lists every integration-scoped verb, in the order clients present them. All are checked on integrations.patchy.bitwisemedia.uk, the same resource the admission policy's authorizer names. That keeps the CLI/status-server SubjectAccessReviews and the server-side enforcement in agreement.
Functions ¶
func Apply ¶
Apply records verb on f as user at time now, mutating f's spec only. A human action never writes status and never moves a phase itself. The phase-owning controller observes the spec change and performs the transition, which keeps every phase edge single-writer.
changed reports whether f was actually modified. An action whose effect is already recorded returns (false, nil): callers skip the write rather than churning resourceVersion. note is recorded on approvals and ignored by every other verb.
Callers running under conflict retry must call Apply again after every re-Get, so the gating is re-evaluated against fresh state.
func Available ¶
Available reports the verbs that would actually do something to f at time now, in ActionVerbs order. It probes Apply against a copy rather than re-stating the gates, so the two can never disagree.
It answers "is there anything to do here", not "may this user do it". A caller still has to check its own grants.
Types ¶
This section is empty.