Module sat_file

Module sat_file 

Source
Expand description

Jinja2 rendering helpers for SAT (System Admin Toolkit) template files and a structure-aware filter that operates on the parsed serde_json::Value.

The canonical SAT-file schema lives in csm-rs (which parses the value into typed structs during apply). The CLI never carries the typed schema โ€” it only needs to:

  1. Render Jinja2 templates with a values file + --var overrides (the renderer takes parsed YAML as Jinja context for the values file but produces a string for the SAT file content).
  2. Parse the rendered SAT string into a serde_json::Value so the server can forward it verbatim.
  3. Apply --image-only / --sessiontemplate-only filters by walking the Value (drop top-level sections plus prune unreferenced configurations/images) before sending.

Both --image-only and --sessiontemplate-only preserve the historical CLI semantics:

  • --image-only: drops session_templates + hardware; retains only configurations referenced by the remaining images.
  • --sessiontemplate-only: drops hardware; retains images only if named in a session_template; drops the images section entirely if no image survives; retains only configurations referenced by surviving images or session_templates.

The walk navigates a small set of field names (configurations, images, session_templates, hardware, name, configuration, image, image_ref, ims) โ€” no struct schema is embedded here.

Functionsยง

apply_sat_file_filters
Apply --image-only / --sessiontemplate-only filters to a parsed SAT file in-place.
render_jinja2_sat_file_yaml
Render a SAT file as a Jinja2 template, optionally merging a values file and CLI-provided overrides in dot notation. Returns the rendered SAT YAML as a string โ€” callers parse it into the structured value they need (CLI parses to serde_json::Value).