cmd: validate telemetry.path and scrape.timeout-margin, warn on unknown disabled collectors (#2733)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-16 09:11:02 +02:00
committed by GitHub
parent a3692d335a
commit 41f8bfb352
5 changed files with 268 additions and 25 deletions
+16 -9
View File
@@ -167,15 +167,22 @@ func TestNewConfigFileResolverFlags(t *testing.T) {
// kingpin's built-in flags, like --help, are not configuration options.
builtin := kingpin.New("test", "test")
for _, flag := range newApp(mainFlags).Model().Flags {
switch {
case builtin.GetFlag(flag.Name) != nil,
// selects the configuration file itself
flag.Name == "config.file",
// prints the available sub-collectors and exits
flag.Name == "collector.exchange.list",
// CLI-only diagnostic mode; not valid in a config file
flag.Name == "scrape.stdout":
// cliOnly lists the flags that have no configuration file key by design.
cliOnly := map[string]string{
"config.file": "selects the configuration file itself",
"collector.exchange.list": "prints the available sub-collectors and exits",
"scrape.stdout": "CLI-only diagnostic mode; not valid in a config file",
}
app := newApp(mainFlags)
// A renamed or removed flag must not stay exempt under its old name.
for name := range cliOnly {
require.NotNil(t, app.GetFlag(name), "the CLI-only flag %s does not exist", name)
}
for _, flag := range app.Model().Flags {
if _, ok := cliOnly[flag.Name]; ok || builtin.GetFlag(flag.Name) != nil {
continue
}