pub struct HookRunContext<'a> {
pub dry_run: bool,
pub log: &'a StageLogger,
pub template_vars: Option<&'a TemplateVars>,
pub build_env: Option<&'a HashMap<String, String>>,
pub extra_env: Option<&'a [(String, String)]>,
}Expand description
Cross-cutting inputs for run_hooks that stay constant across every
hook in a single invocation. Bundled into one struct so call sites read
as named fields instead of a run of positional bool / Option
arguments. Cheap to pass by value — every field is Copy.
Fields§
§dry_run: boolLog each hook command instead of executing it.
log: &'a StageLoggerSink for status lines and captured command output.
template_vars: Option<&'a TemplateVars>When set, hook cmd / dir / env / if are Tera-expanded with
these vars before execution, supporting
conditionals, filters, and {{ .Env.VAR }}. None runs the literal
command with no rendering.
build_env: Option<&'a HashMap<String, String>>The active build’s per-target builds[].env map (already
rendered/expanded by the build planner). It layers BETWEEN the
inherited process env (base) and each hook’s own env: (most
specific) — hook env: entries are appended after the build env,
so a key present
in both resolves to the hook value. None (the default via
HookRunContext::new) at non-build hook sites — they have no
build env.
extra_env: Option<&'a [(String, String)]>Extra environment variables the hook site injects into the hook
process (e.g. the ANODIZER_* failure-context vars set by publish
on_error hooks). The env channel exists so untrusted values (error
bodies, remote stderr) reach hooks WITHOUT being interpolated into
the sh -c command string, where shell metacharacters would be
command injection. Layered after build_env and before each hook’s
own env: entries, so hook env: still wins on key conflicts.
Implementations§
Source§impl<'a> HookRunContext<'a>
impl<'a> HookRunContext<'a>
Sourcepub fn new(
dry_run: bool,
log: &'a StageLogger,
template_vars: Option<&'a TemplateVars>,
) -> Self
pub fn new( dry_run: bool, log: &'a StageLogger, template_vars: Option<&'a TemplateVars>, ) -> Self
Context for a non-build hook run (the common case): no per-target
build_env. Build sites construct the struct directly and set
HookRunContext::build_env.
Sourcepub fn with_extra_env(self, extra_env: &'a [(String, String)]) -> Self
pub fn with_extra_env(self, extra_env: &'a [(String, String)]) -> Self
Attach site-injected env vars (see HookRunContext::extra_env).
Trait Implementations§
Source§impl<'a> Clone for HookRunContext<'a>
impl<'a> Clone for HookRunContext<'a>
Source§fn clone(&self) -> HookRunContext<'a>
fn clone(&self) -> HookRunContext<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more