Solves #2602 - the new version of alertmanager introduces an isEqual
flag to support != matchers in alertmanager silences. Clients set this
to true in the JSON blob sent to the api to indicate a foo=bar matcher,
and to false to indicate foo!=bar. Due to gos unmarshalling, anything
that _doesn't_ include this flag will default to false (i.e. a !=
matcher), so any clients that aren't aware of this flag (such as amtools
before negative matchers and the new api) will not send it, and when you
think you are making a foo=bar matcher, alertmanager will interpret that
as a not equals.
This commit changes the Unmarshaling of the v1matcher struct to default
the IsEqual flag to true, to keep the old behaviour for clients not
setting the flag
Signed-off-by: sinkingpoint <colin@quirl.co.nz>
Previously, escaped double quotes would still be seen as ending the
quoting, potentially leading to wronk tokenization.
Signed-off-by: beorn7 <beorn@grafana.com>
This addresses a number of issues:
- It was impossible to include a literal '"' or a line break in the value.
- It was impossible to include '=', '~', or '!' in the value.
- It was not validated if the label name is valid.
- It was not validated if the value is valid UTF-8.
- No whitespace was allowed around the operator.
Signed-off-by: beorn7 <beorn@grafana.com>
The doc comments do not describe the current (arguably buggy) state,
but the desired state, as it will be implemented in future commits.
Signed-off-by: beorn7 <beorn@grafana.com>
* api/v2: add path and method to API v2 logs
When an API v2 handler logged a message, the log wouldn't include the
path and method. Since different handlers perform the same validations
(e.g. matchers for alerts and silences), it isn't easy to know which
handler was invoked (though the logged filename
+ line number provides a hint).
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Capitalize messages + improve logs
Signed-off-by: Simon Pasquier <spasquie@redhat.com>