pub struct TemplateContext {
pub vars: HashMap<String, Value>,
pub matrix: HashMap<String, Value>,
pub otel: HashMap<String, Value>,
}Expand description
Template context with vars, matrix, otel namespaces
Provides structured access to template variables:
vars.*- User-defined variablesmatrix.*- Matrix testing parametersotel.*- OpenTelemetry configuration
Fields§
§vars: HashMap<String, Value>User-defined variables
matrix: HashMap<String, Value>Matrix testing parameters
otel: HashMap<String, Value>OpenTelemetry configuration
Implementations§
Source§impl TemplateContext
impl TemplateContext
Sourcepub fn new() -> TemplateContext
pub fn new() -> TemplateContext
Create new empty template context
Sourcepub fn with_defaults() -> TemplateContext
pub fn with_defaults() -> TemplateContext
Create context with default PRD v1.0 variables resolved via precedence
Resolves standard variables following precedence:
- svc: SERVICE_NAME → “clnrm”
- env: ENV → “ci”
- endpoint: OTEL_ENDPOINT → “http://localhost:4318”
- exporter: OTEL_TRACES_EXPORTER → “otlp”
- image: CLNRM_IMAGE → “registry/clnrm:1.0.0”
- freeze_clock: FREEZE_CLOCK → “2025-01-01T00:00:00Z”
- token: OTEL_TOKEN → “”
Sourcepub fn add_var_with_precedence(
&mut self,
key: &str,
env_key: &str,
default: &str,
)
pub fn add_var_with_precedence( &mut self, key: &str, env_key: &str, default: &str, )
Add variable with precedence resolution
Resolves value with priority: existing var → ENV → default
§Arguments
key- Variable nameenv_key- Environment variable namedefault- Default value if not found
Sourcepub fn with_vars(self, vars: HashMap<String, Value>) -> TemplateContext
pub fn with_vars(self, vars: HashMap<String, Value>) -> TemplateContext
Set user-defined variables
Sourcepub fn with_matrix(self, matrix: HashMap<String, Value>) -> TemplateContext
pub fn with_matrix(self, matrix: HashMap<String, Value>) -> TemplateContext
Set matrix testing parameters
Sourcepub fn with_otel(self, otel: HashMap<String, Value>) -> TemplateContext
pub fn with_otel(self, otel: HashMap<String, Value>) -> TemplateContext
Set OpenTelemetry configuration
Sourcepub fn to_tera_context(&self) -> Result<Context, TemplateError>
pub fn to_tera_context(&self) -> Result<Context, TemplateError>
Convert to Tera context for rendering
Injects variables at both top-level (no prefix) and nested [vars] for authoring. This matches PRD v1.0 requirements for no-prefix template variables.
Sourcepub fn add_matrix_param(&mut self, key: String, value: Value)
pub fn add_matrix_param(&mut self, key: String, value: Value)
Add a matrix parameter
Sourcepub fn add_otel_config(&mut self, key: String, value: Value)
pub fn add_otel_config(&mut self, key: String, value: Value)
Add an OTEL configuration value
Sourcepub fn merge_user_vars(&mut self, user_vars: HashMap<String, Value>)
pub fn merge_user_vars(&mut self, user_vars: HashMap<String, Value>)
Merge user-provided variables with defaults
User variables take precedence over defaults (implements precedence chain)
Trait Implementations§
Source§impl Clone for TemplateContext
impl Clone for TemplateContext
Source§fn clone(&self) -> TemplateContext
fn clone(&self) -> TemplateContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TemplateContext
impl Debug for TemplateContext
Source§impl Default for TemplateContext
impl Default for TemplateContext
Source§fn default() -> TemplateContext
fn default() -> TemplateContext
Auto Trait Implementations§
impl Freeze for TemplateContext
impl RefUnwindSafe for TemplateContext
impl Send for TemplateContext
impl Sync for TemplateContext
impl Unpin for TemplateContext
impl UnwindSafe for TemplateContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request