Documentation
¶
Overview ¶
Package conf loads the typed configuration behind chok.Load.
Sources, lowest to highest: `default` tags, the YAML file, environment variables named after the key path ({PREFIX}_HTTP_ADDR), then flags named after it (--http.addr). Decoding is strict: an unknown key or section is an error with a suggestion, a value of the wrong shape is an error naming its path. Validation runs the `validate` tags and then every Validate method. All problems are reported together.
Index ¶
Constants ¶
const Masked = "***"
Masked replaces a non-empty secret in Dump output.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check runs the validate tags and Validate methods on the struct v points to, as Load does, for configuration built in code.
func Defaults ¶
Defaults sets every field of the struct dst points to that has a `default` tag, at any depth; fields without one keep their value.
func Dump ¶
Dump renders v as YAML under its yaml key names, with every field tagged secret:"true" masked. It is what --check-config prints.
Types ¶
type Key ¶
type Key struct {
Path string
Type string
Default string
Secret bool
// Rules is the field's validate tag.
Rules string
// Decl is the named struct type whose declaration holds the field and
// Field the Go field names leading from it to the field: one name, or
// more when the field sits in an anonymous struct, as the sections of
// telemetry.Config and cache.Config do. chok docs gen reads the
// field's comment through them.
Decl reflect.Type
Field []string
}
Key describes one leaf of a configuration type, for documentation and for the configkeys budget. Map entries appear once with "<name>" for the key and list elements with "[]".
type Options ¶
type Options struct {
// Name is the application name: it derives the environment prefix
// and the file candidates {name}.yaml and configs/{name}.yaml.
Name string
// EnvPrefix overrides the prefix derived from Name.
EnvPrefix string
// Override is the file named on the command line (--config); it
// beats {PREFIX}_CONFIG and File. A missing one is an error.
Override string
// File is the file the code names (ConfigFile); a missing one is an
// error.
File string
// Flags is a parsed flag set; changed flags named after a key path win.
Flags *pflag.FlagSet
// Environ is the environment, os.Environ() unless a test sets it.
Environ []string
// Only, when set, loads just these top-level sections of the file:
// the others are skipped rather than reported as unknown, and only
// environment variables inside them can warn. The chok command reads
// the db section of an application's chok.yaml this way, with a type
// that has nothing else.
Only []string
}
Options controls one Load.