Skip to main content

Module candidate

Module candidate 

Source
Expand description

pgroles candidate — file, list, inspect and diff PostgresPolicyCandidate objects.

These commands cover the review side of the candidate workflow documented in docs/src/pages/docs/operator-candidates.md: propose content, see what the operator planned for it, and read the SQL a reviewer would be approving.

Deciding a plan is deliberately not here. A decision is a write to the plan’s status subresource, gated by admission so that decidedBy records an authenticated identity. Wrapping that in a CLI verb would blur who authenticated it, so approval and rejection stay kubectl-shaped — see Deciding a plan.

The Kubernetes objects are read as DynamicObject rather than through the operator’s typed CRD structs: the CLI does not depend on pgroles-operator, and a second copy of those types in this crate would be a second definition of the API. Everything below therefore navigates serde_json::Value, which also makes the formatting and selection logic unit-testable against literals.

Structs§

CandidateRow
One row of pgroles candidate list.
Condition
A condition read off a candidate or plan status.

Enums§

PlanSqlSource
Where a plan’s reviewed SQL actually lives.

Constants§

CONTENT_KEYS
The keys PostgresPolicyCandidate.spec.content accepts, in the CRD’s own spelling. Anything outside this set is either dropped as execution config (see POLICY_EXECUTION_KEYS) or rejected — never silently pruned by the API server, which would change the content digest without saying so.
POLICY_EXECUTION_KEYS
PostgresPolicy.spec keys that describe execution, not content. A candidate always takes these from its parent policy, so they are dropped when a whole policy manifest is filed as a candidate.

Functions§

abbreviate_digest
Shorten a sha256:… digest for table display. Full digests are 71 characters and would swamp every other column.
build_candidate_object
Build the PostgresPolicyCandidate object to create.
candidate_row
Project a candidate object into a table row.
cmd_create
pgroles candidate create — validate a local manifest and file it.
cmd_diff
pgroles candidate diff — the SQL approving this candidate’s plan would run.
cmd_list
pgroles candidate list — candidates filed against one policy.
cmd_status
pgroles candidate status — one candidate and its plan in detail.
decode_configmap_sql
Read the SQL out of the ConfigMap a plan’s sqlRef names.
extract_candidate_content
Extract the spec.content mapping from a local manifest.
find_condition
Read a condition of the given type from an object’s status.conditions.
format_candidate_status
Render pgroles candidate status for one candidate and its plan.
format_candidate_table
Render rows as a padded table. kubectl-shaped so the output can be read beside kubectl get pgcand without retraining the eye.
format_plan_decision
The plan’s write-once decision, and who made it.
format_plan_staleness
Whether the plan still describes the candidate’s effects.
format_promotion_outcome
What promotion has to say about this candidate, if anything.
generate_name_prefix
Kubernetes appends five random characters to generateName and rejects the result past 253 characters, so the prefix is capped to leave room.
select_plan_sql
Decide where to read a plan’s SQL from.
string_at
Read a dotted path of string-keyed fields, e.g. status.planRef.name.