Commit Graph

7 Commits

Author SHA1 Message Date
George Robinson ca5089d33e
Support UTF-8 label matchers: Rename feature flags and make package public (#3604)
* Rename feature flags and make package public

This commit renames the feature flags "classic-matchers-parsing"
and "utf8-matchers-parsing" to "classic-matchers" and "utf8-matchers".
This better represents their use, for example, when validating
both alerts and silences created via the API.

It also makes the feature flags package public for two reasons:

1. AllowedFlags is a public variable
2. We would rather use these consts in Mimir then have to hardcode
   the strings ourselves, and be subject to breaking changes in future

Signed-off-by: George Robinson <george.robinson@grafana.com>
---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-11-17 20:07:54 +00:00
George Robinson f96ba1b58f
unquote should check for invalid UTF-8 code points (#3595)
Quoted tokens can contain both UTF-8 byte and code point literals
that should be interpreted when quoted. However, we need to check
that the interpreted literals are valid UTF-8 code points or not.
This now happens in unquote.

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-11-13 16:31:15 +00:00
George Robinson 7cdecbf6ee
Remove braces from suggestion (#3568)
This commit removes the open and close braces from the suggestion
as braces do not make sense in the configuration file. This does
not change the behavior of the suggestion whatsoever as these
are optional.

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-10-30 14:30:19 +00:00
George Robinson b5b5a1df3d
Support UTF-8 label matchers: Do not allow unquoted escape sequences (#3571)
* Do not allow unquoted escape sequences

This commit updates the matchers parser to reject unquoted
openmetrics escape sequences. As an example, foo=bar\n
will no longer parse, and must instead be written as
foo="bar\n". This avoids an issue where the input is valid
in both the matchers and classic parsers, but results
in two different parsings.

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-10-30 13:56:54 +00:00
George Robinson 8512285e54
Support UTF-8 label matchers: Update compliance tests (#3569)
* Update compliance tests

This commit updates compliance tests to include openmetrics
escape sequences that are not valid in the UTF-8 matchers parser.

Signed-off-by: George Robinson <george.robinson@grafana.com>

* Add tests for openmetrics escape sequences

Signed-off-by: George Robinson <george.robinson@grafana.com>

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-10-25 09:52:17 +01:00
George Robinson 16aa996c4f
Support UTF-8 label matchers: Add compat package with feature flag and use in amtool (#3483)
* Add adapter package for parser feature flag

This commit adds the compat package allowing users to switch
between the new matchers/parse parser and the old pkg/labels parser.
The new matchers/parse parser uses a fallback mechanism where if
the input cannot be parsed in the new parser it then attempts to
use the old parser. If an input is parsed in the old parser but
not the new parser, then a warning log is emitted.

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-10-19 12:00:01 +01:00
George Robinson 353c0a1304
Support UTF-8 label matchers: Add new parser (#3453)
* Add label matchers parser

This commit adds the new label matchers parser as proposed in #3353.
Included is a number of compliance tests comparing the grammar
supported in the new parser with the existing parser in pkg/labels.

Signed-off-by: George Robinson <george.robinson@grafana.com>
---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-09-05 11:32:58 +01:00