Commit graph

19 commits

Author SHA1 Message Date
Nick Moore c05ebef306
Implement SanitizeLabelName and Full variant
Rather than removing the previous implementation of SanitizeLabelName,
offer another version named SanitizeFullLabelName that achieved the
desired requirements, without breaking existing Prometheus code.

Update testing to validate correctness of new variant.

Signed-off-by: Nick Moore <nicholas.moore@grafana.com>
2023-02-03 15:28:33 +00:00
Nick Moore 758914e1fb
Fix SanitizeLabelName for certain invalid labels
SanitizeLabelName was not correctly sanitizing label names that:

1. Started with a digit (0-9)
2. Were empty

This commit changes the santization code to catch both of these edge
cases and adds new tests to validate it works correctly in them both. In
the first case, a leading digit will be replaced with an underscore, and
in the latter, the function will return a single underscore.

Signed-off-by: Nick Moore <nicholas.moore@grafana.com>
2023-02-03 08:53:10 +00:00
Julien Pivotto 96d5a32659
Update go to 1.19, set min version to 1.18 (#11279)
* Update go to 1.19, set min version to 1.18

Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>

* Update golangci-lint

Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>

Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
2022-09-07 11:30:48 +02:00
Julien Pivotto 9a2e93228e
Switch to grafana/regexp everywhere (#10268)
Let's have a consistent library for regexp.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2022-02-13 00:58:27 +01:00
Julius Volz 2c49860f69 Add license notice for code adapted from Go
Fix https://github.com/prometheus/prometheus/issues/9884

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2021-12-05 09:01:52 +01:00
Mateusz Gozdek 1a6c2283a3 Format Go source files using 'gofumpt -w -s -extra'
Part of #9557

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-02 19:52:34 +01:00
Paweł Szulik f5563bfe95
tests: Move from t.Errorf and others. (Part 2) (#9309)
* Refactor util tests.

Signed-off-by: Paweł Szulik <paul.szulik@gmail.com>
2021-09-13 21:19:20 +02:00
Guangwen Feng f50786bcd1
Add unit test case to improve test coverage for quote.go (#7482)
Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
2020-06-30 10:33:02 +02:00
Simon Pasquier 45506841e6
*: enable all default linters (#5504)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-05-03 15:11:28 +02:00
Tariq Ibrahim a188693015 Adding unit tests for the util package (#4534)
Signed-off-by: Tariq Ibrahim <tariq.ibrahim@microsoft.com>
2018-08-27 15:55:49 +01:00
beorn7 094a098ce6 Revert "Revert the /graph changes."
This reverts commit aa43d34a86.

This brings back the /graph changes so that @grandbora can continue to
work on the redirect for backwards compatibility. And other changes
can already take the new /graph parameters into account.
2016-09-03 21:05:23 +02:00
beorn7 aa43d34a86 Revert the /graph changes.
This revert will be reverted once v1.1 is released and has its own
release branch. Since we had already change on top of this, there was
no cleaner way of cutting those changes out.

This commit reverts the following commits:

Revert "Update backend helpers and templates to new url schema"
This reverts commit fc6cdd0611.

Revert "Refactor graph.js"
This reverts commit 445fac56e0.

Revert "Use query parameters in the url"
This reverts commit 3e18d86d8a.

Revert "Point to correct place for GraphLinkForExpression"
This reverts commit 3da825fc76.

Assets are also updated.
2016-09-02 13:59:09 +02:00
Bora Tunca fc6cdd0611 Update backend helpers and templates to new url schema 2016-08-08 09:52:14 +02:00
beorn7 a7408bfb47 Unify duration parsing
It's actually happening in several places (and for flags, we use the
standard Go time.Duration...). This at least reduces all our
home-grown parsing to one place (in model).
2016-01-29 15:41:50 +01:00
Julius Volz 46c5260761 Support escape sequences in strings and add raw strings.
This adapts some functionality from the Go standard library for string
literal lexing and unquoting/unescaping.

The following string types are now supported:

Double- or single-quoted strings:

  These support all escape sequences that Go supports in double-quoted
  string literals. The difference is that Prometheus also has
  single-quoted strings (instead of single-quoted runes in Go). Raw
  newlines are not allowed.

Backtick-quoted raw strings:

  Strings quoted in backticks are treated as raw strings just like in Go
  and may contain raw newlines and other special characters directly.

Fixes https://github.com/prometheus/prometheus/issues/1122
Fixes https://github.com/prometheus/prometheus/issues/1121
2015-10-08 19:17:21 +02:00
Julius Volz 7e86cd1ef4 Add Unquote() strutil function. 2015-09-30 21:56:25 +02:00
Jimmi Dyson 923f8111d4 Initial Kubernetes discovery
Fixes #904
2015-08-13 10:38:52 +01:00
Fabian Reinartz 183be62f2a util/strutil: do not panic on wrong duration unit. 2015-06-04 14:02:36 +02:00
Fabian Reinartz 0de6edbdfc Move pkg/ to util/ 2015-06-01 21:12:32 +02:00