Skip to content

Commit

Permalink
fix: sort tenants in the validator human readable output
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
  • Loading branch information
FUSAKLA committed Mar 7, 2024
1 parent 6d5c48e commit 236a949
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [2.12.0] - 2024-03-07
- Fixed resolving of the path in `paramsFromFile`. Formerly it was resolved from the current working directory, now it must be a relative path, that will be resolved from the config file location.
- Fixed: tenants in the `hasSourceTenantsForMetrics` validator are now sorted in the human readable output.

## [2.11.0] - 2024-03-07
- :warning: CHANGED: Params of the `hasSourceTenantsForMetrics` validator (again FACEPALM). Now the tenant can have multiple regexp matchers.
Expand Down
11 changes: 8 additions & 3 deletions pkg/validator/others.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ type hasSourceTenantsForMetrics struct {

func (h hasSourceTenantsForMetrics) String() string {
tenantStrings := []string{}
for tenant, metrics := range h.sourceTenants {
for _, m := range metrics {
tenantStrings = append(tenantStrings, fmt.Sprintf("`%s`: `%s` (%s)", tenant, m.regexp.String(), m.description))
tenants := make([]string, 0, len(h.sourceTenants))
for tenant := range h.sourceTenants {
tenants = append(tenants, tenant)
}
slices.Sort(tenants)
for _, t := range tenants {
for _, m := range h.sourceTenants[t] {
tenantStrings = append(tenantStrings, fmt.Sprintf("`%s`: `%s` (%s)", t, m.regexp.String(), m.description))
}
}
return fmt.Sprintf("rule group, the rule belongs to, has the required `source_tenants` configured, according to the mapping of metric names to tenants: \n %s", strings.Join(tenantStrings, "\n "))
Expand Down

0 comments on commit 236a949

Please sign in to comment.