Documentation
¶
Overview ¶
Package secret provides SecretRef, a secret-bearing configuration value that is either a literal or a scheme-prefixed reference (env:, file:, literal:) resolved to its concrete value on demand. It is a small, dependency-free primitive so any package or module can reference secrets without depending on a larger consumer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SecretRef ¶
type SecretRef string
SecretRef is a secret-bearing configuration value: a literal, or a reference whose scheme prefix names where the value comes from. It is the raw string as written in config — it unmarshals from and marshals to a plain JSON string, so only the single prefixed-string form is supported; there is intentionally no object form.
"plain-value" // literal (the default, backward compatible) "env:NAME" // read from environment variable NAME "file:/path/to/file" // read from a file (trailing whitespace trimmed) "literal:env:foo" // explicit literal escape hatch
A value whose prefix is not a known scheme (including one with no colon at all) is treated as a literal. Resolution — the I/O — is a separate step; see Resolve.
func (SecretRef) Resolve ¶
Resolve reads the concrete value for the reference. This is the single I/O seam: the only place that reads env/files and the only place that can fail. A missing env var or an unreadable/empty file is a loud error — a reference never silently resolves to the empty string. A literal is returned as-is; an empty literal (or the zero value) is allowed for backward compatibility.