Skip to content

Support multiple config files via repeatable -config flag #2865

Description

@renuka-fernando

Description

Allow the gateway to accept multiple configuration files via a repeatable -config flag (e.g. -config base.toml -config prod.toml), so config can be layered as a complete base file plus thin environment/deployment overlays instead of a single monolithic file. This applies to both gateway binaries — the gateway-controller and the gateway-runtime policy-engine.

Behavior

  • The -config flag becomes repeatable. Files are merged in the order given, with last-wins precedence (a key set in a later file overrides the same key from an earlier file).
  • Merge semantics follow koanf: nested tables (maps) deep-merge; list/array values are replaced, not appended. This must be documented so overlays that set list keys (e.g. enabled_publishers, ignore_path_prefixes) are understood to replace the base list.
  • Use koanf StrictMerge (or WithMergeFunc) so a type-mismatched override across files fails loudly rather than silently.
  • {{ env }} / {{ file }} interpolation runs once, after all files are merged, so a token declared in the base can be resolved by a later overlay. Secrets stay in interpolation sources, not in the overlay TOMLs.
  • At least one -config file remains required and there is no default config file path: omitting -config, or passing a path that does not exist/parse, must fail fast rather than silently boot on built-in defaults. The flag help text documents the repeatable + last-wins behavior.

Scope

Affected code

  • gateway/gateway-controller/cmd/controller/main.go — replace the single flag.String("config", ...) with a repeatable flag.Var slice.
  • gateway/gateway-controller/pkg/config/config.goLoadConfig loops k.Load(file.Provider(p), toml.Parser()) over all paths in order; interpolate/unmarshal/validate on the merged result.
  • gateway/gateway-runtime/policy-engine/cmd/policy-engine/main.go — same repeatable flag.Var change; require at least one file.
  • gateway/gateway-runtime/policy-engine/internal/config/config.goLoad becomes variadic, loops the file loads with a StrictMerge koanf instance, and drops the previous optional-file branch so the loader fails closed instead of silently running on defaults (aligning the loader with the already-required flag).

Version

No response

Related Issue

No response

Metadata

Metadata

Labels

Area/GatewayAny issues related to API deployment in gateway, routing etc.Aspect/ConfigurationConfig files, settings, env vars, defaultsType/Improvement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions