docs/config/README.md
The Agent Configuration is the primary mechanism for configuring Consul. Agent Configuration also allows for specifying Config Entries, Services, and Checks that will be loaded when the agent starts.
Most configuration comes from hcl or json files, but some configuration can also be
specified using command line flags, and some can be loaded with Auto-Config.
See also the checklist for adding a new field to the configuration.
The Agent Configuration is implemented in agent/config, and the primary entrypoint is Load. Config loading is performed in phases:
config.LoadOpts and passed to Load.Load reads all the config files and builds an ordered list of config.Source.config.Source is read to produce a config.Config.config.Config is merged ontop the previous.config.RuntimeConfig is produced from the merged config.Configconfig.RuntimeConfig is validated.RuntimeConfig and any warnings, or an error.If Auto-Config is enabled, when it receives the config from the server, the
entire process is repeated a second time with the addition config provided as another
config.Source.
Default values can be specified in one of the default sources or set when
converting from Config to RuntimeConfig in builder.build. Hopefully in the future we
should remove one of those ways of setting default values.
Auto-Config is enabled by the auto_config field in an Agent Configuration file. It is implemented in a couple packages.