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 with_defaults() -> Self
pub fn with_defaults() -> Self
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_matrix(self, matrix: HashMap<String, Value>) -> Self
pub fn with_matrix(self, matrix: HashMap<String, Value>) -> Self
Set matrix testing parameters
Sourcepub fn to_tera_context(&self) -> Result<Context>
pub fn to_tera_context(&self) -> Result<Context>
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 more