Expand description
Testable CLI logic for pgroles.
All pure functions that don’t require a live database connection live here.
The binary (main.rs) delegates to these, making validation, plan formatting,
and output rendering fully unit-testable.
Modules§
- candidate
pgroles candidate— file, list, inspect and diffPostgresPolicyCandidateobjects.
Structs§
- Plan
Summary - Summary statistics for a plan.
- Validated
Bundle - The result of successfully validating a composed policy bundle.
- Validated
Manifest - The result of successfully validating a manifest.
Constants§
- RENDERED_
MANIFEST_ SCHEMA - Schema identifier for the YAML body emitted by
render-bundle. Bumped only on incompatible changes to thePolicyManifestserialization shape. Recorded in the header so--checkfailures after a pgroles upgrade can be diagnosed as “schema bump → re-render required” rather than mystery drift, and so consumers parsing the rendered file can detect mismatches.
Functions§
- apply_
role_ retirements - Insert explicit retirement actions before any matching role drops.
- compute_
plan - Compute the list of changes needed to bring
currentstate todesiredstate. - format_
bundle_ plan_ json - Format a bundle plan as JSON with ownership annotations for each change.
- format_
bundle_ validation_ result - Format bundle validation results for human-readable output.
- format_
managed_ scope_ summary - Format a composed managed scope for human-readable debug output.
- format_
plan_ json - Format a plan as JSON for machine consumption.
- format_
plan_ sql - Format a plan as SQL statements.
- format_
plan_ sql_ with_ context - Format a plan as SQL statements using an explicit SQL context.
- format_
rendered_ bundle - Render a validated bundle as a single composed manifest YAML.
- format_
role_ graph_ summary - Format a RoleGraph as a human-readable summary.
- format_
validation_ result - Format validation results for human-readable output.
- inject_
password_ changes - Inject
SetPasswordchanges into a plan for roles with resolved passwords. - parse
- Parse and validate a YAML string into a
PolicyManifest. - parse_
and_ expand - Parse, validate, and expand a manifest YAML string into an
ExpandedManifest. - planned_
role_ drops - Collect the role names that the current plan intends to drop.
- read_
manifest_ file - Read a manifest file from disk and return the raw YAML string.
- resolve_
passwords - Resolve password sources from environment variables for roles that declare them.
- validate_
bundle_ file - Load, validate, and compose a policy bundle from disk.
- validate_
manifest - Full validation: parse, expand, and build a RoleGraph from a manifest string. Returns the expanded manifest and the desired RoleGraph.