MacroPostProcessor

Struct MacroPostProcessor 

Source
pub struct MacroPostProcessor { /* private fields */ }
Expand description

Post-processor for macro variable scoping

Implementations§

Source§

impl MacroPostProcessor

Source

pub fn from_yaml(yaml_content: &str) -> Result<Self, Error>

Create a new processor from values.yaml content

Source

pub fn from_value(value: &Value) -> Self

Create from a pre-parsed YAML value

Source

pub fn resolve(&self, variable: &str) -> ResolvedVariable

Resolve a bare variable name to its full path

Source

pub fn resolve_with_hint(&self, variable: &str, hint: &str) -> ResolvedVariable

Resolve a variable with a hint about the expected parent path segment

For example, if the variable is chroot and the hint is image, prefer values.controller.image.chroot over other paths.

Source

pub fn extract_macros(content: &str) -> Vec<MacroDefinition>

Extract all macro definitions from a template

Source

pub fn find_bare_variables(macro_body: &str) -> Vec<String>

Find bare variable references in a macro body

Returns variable names that are:

  • Not prefixed with values., release., pack., capabilities., _with_ctx.
  • Not Jinja2 keywords or builtin functions
  • Inside expressions ({{ }}) or control structures ({% %})
  • Not loop or set variable declarations
Source

pub fn process(&self, content: &str) -> (String, Vec<UnresolvedVariable>)

Process a template, resolving bare variables in macros

Returns the processed content and a list of variables that couldn’t be resolved

Trait Implementations§

Source§

impl Debug for MacroPostProcessor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.