Skip to main content

format_rendered_bundle

Function format_rendered_bundle 

Source
pub fn format_rendered_bundle(
    validated: &ValidatedBundle,
    source_label: &str,
    include_header: bool,
) -> Result<String>
Expand description

Render a validated bundle as a single composed manifest YAML.

When include_header is true, the output is prefixed with a YAML comment block recording the source bundle label, the manifest schema version against which the body was rendered, and the fragments it composed, for traceability when the rendered file is committed to a GitOps repo.

source_label should be a stable, machine-independent label (e.g. the bundle file’s basename). Callers must NOT pass absolute or pwd-relative paths: the rendered output is intended to be byte-identical across developer machines and CI runners, and embedding a local filesystem path in the header would break that contract.

The body is the composed PolicyManifest serialized via serde_yaml and then post-processed to drop noise that would otherwise churn under upgrades or render in irrelevant places: null scalars, empty sequences (except for required-field keys like members/privileges/grant), known empty top-level maps, and known-default scalar values (e.g. the default role_pattern). The cleaned output still round-trips through pgroles validate -f / diff -f / apply -f because the parser fills the same defaults back in on read.