Documentation
¶
Overview ¶
Package envrules holds the one set of rules for env keys and values. Every writer (API, CLI pre-check, import, templates, clone) calls it so a key is accepted or refused the same way on every surface.
Index ¶
Constants ¶
const ( KeyModeStrict = "strict" KeyModeLegacy = "legacy" ModeRefuse = "refuse" ModeWarn = "warn" ModeOff = "off" )
Key policy and refuse-or-warn modes, matching the runtime setting values.
const PreviousSuffix = "_PREVIOUS"
PreviousSuffix mirrors the secret grace key suffix owned by secret rotation.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code string
Code names why a key or value was flagged. UI and CLI map codes to text.
const ( CodeEmptyKey Code = "empty_key" CodeEquals Code = "equals" CodeCharset Code = "charset" CodeLength Code = "length" CodeReserved Code = "reserved" CodePrevious Code = "previous_suffix" CodeDangerous Code = "dangerous" CodeDuplicate Code = "duplicate" CodeNUL Code = "nul" CodeValueSize Code = "value_size" CodeCRLF Code = "crlf" CodeMultiline Code = "multiline" CodeWhitespace Code = "whitespace" CodeInterpolation Code = "interpolation" CodeEmptyValue Code = "empty_value" CodeLegacyKey Code = "legacy_key" CodeSecretOnly Code = "secret_only" )
Codes returned in Issue.Code.
type Existing ¶
Existing is what the app already holds. Plain maps key to current value so an unchanged key is skipped; Names adds keys with no readable value (secrets).
type Issue ¶
type Issue struct {
Key string `json:"key"`
Code Code `json:"code"`
Message string `json:"message"`
}
Issue is one finding for one key. Values never appear in it.
type Options ¶
type Options struct {
// Secret applies the rules for secret keys (the _PREVIOUS grace suffix is reserved).
Secret bool `json:"secret"`
// Multiline marks a path that carries values byte for byte (JSON bodies),
// so a trailing CR is a real value and not a CRLF line-ending leak.
Multiline bool `json:"multiline"`
// ExistingUnknown is set by clients that cannot see the stored keys; the
// server decides about legacy keys.
ExistingUnknown bool `json:"existing_unknown"`
}
Options describe one write.
type Policy ¶
type Policy struct {
KeyMode string `json:"key_mode"`
KeyMaxLen int `json:"key_max_len"`
ValueMaxBytes int `json:"value_max_bytes"`
ReservedPrefixes []string `json:"reserved_prefixes"`
LoaderMode string `json:"loader_mode"`
PathMode string `json:"path_mode"`
}
Policy carries the runtime-setting driven limits.
func DefaultPolicy ¶
func DefaultPolicy() Policy
DefaultPolicy matches the seeded runtime-setting defaults.
type Rejection ¶
type Rejection struct {
Key string `json:"key"`
Code Code `json:"code"`
Reason string `json:"reason"`
}
Rejection is one key the writer refused, with the reason. Values never appear.
type Report ¶
type Report struct {
Accepted []string `json:"accepted"`
Rejected []Rejection `json:"rejected"`
Warnings []Issue `json:"warnings"`
}
Report is the per-key outcome of a bulk write such as a dotenv import.
type Result ¶
Result separates refusals from warnings.
func Validate ¶
Validate checks every key and value in set. Keys already stored with the same value are skipped, so an old legacy entry never blocks an unrelated save.
func ValidateKeys ¶
ValidateKeys checks keys that carry no value (unset, delete, convert): only the shape rules that make a name unusable, so an old odd key can still be removed.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package contract runs the shared envrules fixture through any writer's validation function, so every writer proves the same accept and reject result.
|
Package contract runs the shared envrules fixture through any writer's validation function, so every writer proves the same accept and reject result. |