parse: fix missing argument to fmt.Errorf (#1311)

This commit is contained in:
Simon Pasquier 2018-04-04 10:37:35 +02:00 committed by stuart nelson
parent 4cba49155d
commit cb169a5ec6
2 changed files with 4 additions and 4 deletions

View File

@ -94,9 +94,9 @@ func fetchSilences(filter string) ([]types.Silence, error) {
func query(element *kingpin.ParseElement, ctx *kingpin.ParseContext) error {
var filterString = ""
if len(*silenceQuery) == 1 {
// If we only have one argument then it's possible that the user wants me to assume alertname=<arg>
// Attempt to use the parser to pare the argument
// If the parser fails then we likely don't have a (=|=~|!=|!~) so lets prepend `alertname=` to the front
// If the parser fails then we likely don't have a (=|=~|!=|!~) so lets
// assume that the user wants alertname=<arg> and prepend `alertname=`
// to the front.
_, err := parse.Matcher((*silenceQuery)[0])
if err != nil {
filterString = fmt.Sprintf("{alertname=%s}", (*silenceQuery)[0])

View File

@ -53,7 +53,7 @@ func Matcher(s string) (*labels.Matcher, error) {
func Input(s string) (name, value string, matchType labels.MatchType, err error) {
ms := re.FindStringSubmatch(s)
if len(ms) < 4 {
return "", "", labels.MatchEqual, fmt.Errorf("bad matcher format")
return "", "", labels.MatchEqual, fmt.Errorf("bad matcher format: %s", s)
}
var prs bool