mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-06-19 09:47:29 +02:00
feat(config): warn on unrecognized top-level config sections
A setting nested at the wrong level (e.g. "resampling" placed next to "main" instead of inside it) was silently ignored. Emit a startup warning for any top-level config section not consumed by the backend so such misconfigurations surface instead of failing silently. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 69d1b85c8db3
This commit is contained in:
@@ -91,6 +91,19 @@ func initGops() error {
|
|||||||
func initConfiguration() error {
|
func initConfiguration() error {
|
||||||
ccconf.Init(flagConfigFile)
|
ccconf.Init(flagConfigFile)
|
||||||
|
|
||||||
|
// Warn about unrecognized top-level config sections. A common mistake is
|
||||||
|
// nesting a setting at the wrong level (e.g. placing "resampling" next to
|
||||||
|
// "main" instead of inside it), which is otherwise silently ignored.
|
||||||
|
knownSections := map[string]bool{
|
||||||
|
"main": true, "auth": true, "nats": true, "archive": true,
|
||||||
|
"metric-store": true, "metric-store-external": true, "cron": true, "ui": true,
|
||||||
|
}
|
||||||
|
for _, k := range ccconf.GetKeys() {
|
||||||
|
if !knownSections[k] {
|
||||||
|
cclog.Warnf("ignoring unrecognized top-level config section %q (check nesting in config file)", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cfg := ccconf.GetPackageConfig("main")
|
cfg := ccconf.GetPackageConfig("main")
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
return fmt.Errorf("main configuration must be present")
|
return fmt.Errorf("main configuration must be present")
|
||||||
|
|||||||
Reference in New Issue
Block a user