Expand description
The secret front door — interpolation tokens that let a config name a credential without ever containing one.
Secrets come from the environment, a mounted file, or an interactive
startup prompt: never from the config file and never into a log
line. This module reads a credential from a mounted file (a Kubernetes
Secret volume), trims the trailing newline kubelet leaves on a projected
file, and resolves the two interpolation tokens a declared header value may
carry:
{{secret:NAME}}— the value entered at startup forNAMEunder--prompt-missingif there is one, else the process env varNAME.{{secret-file:PATH}}— the contents of the mounted file atPATH, re-read at the moment of use, so rotating the mounted file takes effect without restarting the daemon.
Both resolve locally — a filesystem path or an env var, never a URL and never a network fetch — so resolving a secret can never itself become an egress channel. The template is structural and may live in the config file or on a flag; the resolved value is materialized only at the instant of use, is never retained, and never reaches a log or error line. That split is what makes “the config file is secret-free” a fact rather than a convention: what the file holds is a reference, not a value.
Functions§
- has_
secret_ ref - Does
valuecontain at least one{{secret:…}}/{{secret-file:…}}ref? The validator uses this to tell a legal secret reference apart from an illegal inline literal under a secret-shaped key: a header namedAuthorizationholding a reference is fine, the same header holding the token itself is a config error. - prompted_
of - read_
token_ file - Read a credential from a mounted file, trimming a single trailing newline
(kubelet projects a Secret value verbatim; an editor or
echocommonly appends a\n). Errors carry the path but never the contents, so a failed read cannot spill the credential into a log or an error line. - refs_
resolvable - Side-effect-free-as-possible pre-flight for
--validate-config/ startup: every ref intemplatemust resolve (the env var is set; the file exists and is readable). Returns the same diagnosticsresolvewould, without retaining the resolved bytes. A{{secret-file:…}}IS read here — an unreadable secret file must fail the config check rather than surface as a mystery 401 on the first outbound request — but the contents are dropped immediately. - resolve
- Resolve every
{{secret:NAME}}/{{secret-file:PATH}}token intemplateagainstenv(the process environment) and the local filesystem, returning the materialized string. Plain text passes through unchanged. A bad token (missing env var, unreadable file, or an unterminated{{) is anErrwith a message that names the ref but never the resolved value. - secret_
available - Whether
{{secret:NAME}}would resolve right now (prompted or environment). - set_
prompted - Record an interactively-entered value for
{{secret:NAME}}resolution.