Documentation
¶
Overview ¶
Package cfgfile implements managed config files (plan §7.4): a SELECTIVE, single-pass renderer that fills ONLY Mooring's own `{{hm.<key>}}` delimiter and copies everything else — the app's `${…}`, `$VAR`, Go `{{ }}`, and even `{{hmFoo}}` (no dot) — byte-identical. It is a byte scanner, NOT a template engine (no conditionals/loops/functions/shell). Output is emitted, never re-scanned, so a resolved secret containing `{{hm.X}}` can't trigger a second pass. Every `{{hm.X}}` resolves only via the file's explicit bindings allowlist and fails closed (never empty string) on anything unknown.
Index ¶
- Variables
- func LiteralSecretLint(body []byte) (string, bool)
- func ParseSource(source string) (kind, arg string, err error)
- func Render(template []byte, resolve Resolver) (out []byte, secretBearing bool, err error)
- func SecretBearing(bindings []Binding) bool
- func ValidKey(key string) bool
- func ValidateBindings(bindings []Binding) error
- type Binding
- type Resolver
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownBinding means a well-formed {{hm.X}} had no binding (fail-closed). ErrUnknownBinding = errors.New("cfgfile: unknown binding") // ErrBadValue means a resolved value contained NUL or CR/LF. ErrBadValue = errors.New("cfgfile: resolved value contains NUL or newline") )
Functions ¶
func LiteralSecretLint ¶
LiteralSecretLint detects credential-shaped LITERALS in a config-file body that has NO secret: binding (plan §7.4): such material should be a {{hm.secret:KEY}} binding, not pasted in clear (which would also be written world-ish and stored unencrypted). Returns a reason + true on a hit.
func ParseSource ¶
ParseSource splits a binding source into its kind and argument, validating the argument grammar per kind. It does NOT resolve anything.
func Render ¶
Render performs the selective substitution. It returns the rendered bytes and whether any secret-bearing binding was used. Any unknown binding, resolve error, or unsafe resolved value is a hard error (fail-closed).
func SecretBearing ¶
SecretBearing reports whether any binding draws from a secret source (so the rendered file must be stored encrypted and written 0600).
func ValidateBindings ¶
ValidateBindings checks the binding set: valid keys, no duplicates, parseable sources. Returns the first violation.