Add config lint command to validate config.toml files
What does this MR do?
Adds a new gitlab-runner lint subcommand that validates a config.toml file for unknown/misspelled keys and structural errors without running the runner.
- Uses
BurntSushi/tomlmetadata to detect undecoded (unknown) keys - Reports all unknown keys clearly with their dotted path
- Exits non-zero on any error (unknown keys, invalid TOML syntax, or missing file)
- Accepts a
--configflag, defaulting to the standard config path - Registers the command in
main.go - Adds tests and testdata fixtures
Why was this MR needed?
Misspelled or misplaced keys in config.toml (e.g. buids_dir instead of builds_dir, or [[runner.kubernetes...]] instead of [[runners.kubernetes...]]) are silently ignored by TOML decoding today, so operators only discover the mistake at runtime when the expected behavior doesn't take effect. This command lets users validate their configuration ahead of time, e.g. in CI or before restarting the runner.
What's the best way to test this MR?
Run the new test suite:
go test ./commands/... -run TestLintConfigFile -v
This covers: a valid config, a misspelled top-level key, a wrong section header, invalid TOML syntax, and a missing file.
You can also try it manually:
gitlab-runner lint --config commands/testdata/lint/misspelled_key.toml
What are the relevant issue numbers?
Closes #38287 (closed)