mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
41c22effbe
With v0.16.0 Alertmanager introduced a new API (v2). This patch adds a configuration option for Prometheus to send alerts to the v2 endpoint instead of the defautl v1 endpoint. Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
44 lines
904 B
Go
44 lines
904 B
Go
package govalidator
|
|
|
|
import "strings"
|
|
|
|
// Errors is an array of multiple errors and conforms to the error interface.
|
|
type Errors []error
|
|
|
|
// Errors returns itself.
|
|
func (es Errors) Errors() []error {
|
|
return es
|
|
}
|
|
|
|
func (es Errors) Error() string {
|
|
var errs []string
|
|
for _, e := range es {
|
|
errs = append(errs, e.Error())
|
|
}
|
|
return strings.Join(errs, ";")
|
|
}
|
|
|
|
// Error encapsulates a name, an error and whether there's a custom error message or not.
|
|
type Error struct {
|
|
Name string
|
|
Err error
|
|
CustomErrorMessageExists bool
|
|
|
|
// Validator indicates the name of the validator that failed
|
|
Validator string
|
|
Path []string
|
|
}
|
|
|
|
func (e Error) Error() string {
|
|
if e.CustomErrorMessageExists {
|
|
return e.Err.Error()
|
|
}
|
|
|
|
errName := e.Name
|
|
if len(e.Path) > 0 {
|
|
errName = strings.Join(append(e.Path, e.Name), ".")
|
|
}
|
|
|
|
return errName + ": " + e.Err.Error()
|
|
}
|