mirror of
https://github.com/AdguardTeam/AdGuardDNS.git
synced 2025-02-20 11:23:36 +08:00
27 lines
542 B
Go
27 lines
542 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"maps"
|
|
"slices"
|
|
|
|
"github.com/prometheus/common/model"
|
|
)
|
|
|
|
// additionalInfo is a extra info configuration.
|
|
type additionalInfo map[string]string
|
|
|
|
// type check
|
|
var _ validator = additionalInfo(nil)
|
|
|
|
// validate implements the [validator] interface for additionalInfo.
|
|
func (c additionalInfo) validate() (err error) {
|
|
for _, k := range slices.Sorted(maps.Keys(c)) {
|
|
if !model.LabelName(k).IsValid() {
|
|
return fmt.Errorf("prometheus labels must match %s, got %q", model.LabelNameRE, k)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|