You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(config): exported strict Decode + ApplyDefaults for embedding AppConfig #8
xpro-ee (private; it builds on xpro-oss as a Go module) needs a config file that is a superset of config.AppConfig, with extra top-level keys for NATS, the watcher, licensing and so on. Right now config.Load decodes into AppConfig with KnownFields(true), so any extra key is rejected. Because expandStrings/expandEnv and the defaulting are unexported, a downstream module would have to copy them. The change itself is generic: it lets any embedding program reuse xpro-oss's strict decode, env expansion and defaults.
Requested by xpro-ee, epic U (see the xpro-ee Roadmap tracker).
Reference behaviour (xpro — read only, do not copy)
xpro/internal/config/config.go:247 runs os.ExpandEnv on the raw YAML text before parsing, so a ${VAR} value containing :, quotes or newlines can rewrite the document. Do not carry this over. xpro-oss's expand-after-parse is the right model, and this issue only exposes it.
Plugs into xpro-oss
config.Load, expandStrings, expandEnv, and the defaults block inside Load.
Scope
func Decode(r io.Reader, v any) error: strict YAML decode (KnownFields(true), empty document OK), then ${VAR} expansion over every string and *string reachable from v.
func (c *AppConfig) ApplyDefaults(): the current defaults (Source.Type="local", Target.DB="postgres", Workers=8), moved out of Load.
Rewrite Load on top of Decode + ApplyDefaults. Behaviour must not change.
Activity