mirror of
https://github.com/prometheus/prometheus.git
synced 2025-12-03 16:41:05 +01:00
Correctly generate rulesLintConfig when --lint=none is set (#17399)
If I run promtool check config --lint=none I get: ``` Checking rules.yml FAILED: rules.yml: unset nameValidationScheme ``` This is becuase passing --lint=none stops newConfigLintConfig from generating rulesLintConfig which is needed for validation. It means that defaults are used then, one of which is unset value for metric name validation, causing this error. Fix this by handling --lint=none case correctly and still generating rulesLintConfig. Fixes #17398. Signed-off-by: Lukasz Mierzwa <l.mierzwa@gmail.com>
This commit is contained in:
parent
5318689046
commit
0e187f5542
@ -476,13 +476,15 @@ type rulesLintConfig struct {
|
||||
}
|
||||
|
||||
func newRulesLintConfig(stringVal string, fatal, ignoreUnknownFields bool, nameValidationScheme model.ValidationScheme) rulesLintConfig {
|
||||
items := strings.Split(stringVal, ",")
|
||||
ls := rulesLintConfig{
|
||||
fatal: fatal,
|
||||
ignoreUnknownFields: ignoreUnknownFields,
|
||||
nameValidationScheme: nameValidationScheme,
|
||||
}
|
||||
for _, setting := range items {
|
||||
if stringVal == "" {
|
||||
return ls
|
||||
}
|
||||
for _, setting := range strings.Split(stringVal, ",") {
|
||||
switch setting {
|
||||
case lintOptionAll:
|
||||
ls.all = true
|
||||
@ -534,9 +536,7 @@ func newConfigLintConfig(optionsStr string, fatal, ignoreUnknownFields bool, nam
|
||||
rulesOptions = nil
|
||||
}
|
||||
|
||||
if len(rulesOptions) > 0 {
|
||||
c.rulesLintConfig = newRulesLintConfig(strings.Join(rulesOptions, ","), fatal, ignoreUnknownFields, nameValidationScheme)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user