From 9a2e93228e63a3fbac950ef0a639f754c3598c5d Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Sun, 13 Feb 2022 00:58:27 +0100 Subject: [PATCH] Switch to grafana/regexp everywhere (#10268) Let's have a consistent library for regexp. Signed-off-by: Julien Pivotto --- .golangci.yml | 4 +--- cmd/prometheus/main.go | 2 +- config/config.go | 2 +- config/config_test.go | 2 +- discovery/file/file.go | 2 +- discovery/http/http.go | 2 +- discovery/puppetdb/puppetdb.go | 2 +- model/relabel/relabel.go | 2 +- promql/engine.go | 2 +- promql/functions.go | 2 +- promql/query_logger_test.go | 2 +- promql/test.go | 2 +- template/template.go | 2 +- util/httputil/cors.go | 3 ++- util/httputil/cors_test.go | 2 +- util/logging/file_test.go | 2 +- util/stats/stats_test.go | 2 +- util/strutil/strconv.go | 3 ++- web/api/v1/api.go | 2 +- web/web.go | 2 +- 20 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 53d890f511..8f7242c9fb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,13 +24,11 @@ linters-settings: depguard: list-type: blacklist include-go-root: true - packages: - - sync/atomic - - github.com/stretchr/testify/assert packages-with-error-message: - sync/atomic: "Use go.uber.org/atomic instead of sync/atomic" - github.com/stretchr/testify/assert: "Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert" - github.com/go-kit/kit/log: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log" + - regexp: "Use github.com/grafana/regexp instead of regexp" errcheck: exclude: scripts/errcheck_excludes.txt goimports: diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index aac0f6339e..6842832c61 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -26,7 +26,6 @@ import ( "os" "os/signal" "path/filepath" - "regexp" "runtime" "strings" "sync" @@ -36,6 +35,7 @@ import ( "github.com/alecthomas/units" "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/regexp" conntrack "github.com/mwitkow/go-conntrack" "github.com/oklog/run" "github.com/pkg/errors" diff --git a/config/config.go b/config/config.go index 4e351666c6..6c66f37c00 100644 --- a/config/config.go +++ b/config/config.go @@ -19,13 +19,13 @@ import ( "net/url" "os" "path/filepath" - "regexp" "strings" "time" "github.com/alecthomas/units" "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/common/config" "github.com/prometheus/common/model" diff --git a/config/config_test.go b/config/config_test.go index 545b3bfd1f..5b78642b81 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -19,12 +19,12 @@ import ( "net/url" "os" "path/filepath" - "regexp" "testing" "time" "github.com/alecthomas/units" "github.com/go-kit/log" + "github.com/grafana/regexp" "github.com/prometheus/common/config" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" diff --git a/discovery/file/file.go b/discovery/file/file.go index 2371ba1941..6d645e90d4 100644 --- a/discovery/file/file.go +++ b/discovery/file/file.go @@ -20,7 +20,6 @@ import ( "io/ioutil" "os" "path/filepath" - "regexp" "strings" "sync" "time" @@ -28,6 +27,7 @@ import ( "github.com/fsnotify/fsnotify" "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/config" diff --git a/discovery/http/http.go b/discovery/http/http.go index ee3643fdb8..6dd949e474 100644 --- a/discovery/http/http.go +++ b/discovery/http/http.go @@ -21,12 +21,12 @@ import ( "io/ioutil" "net/http" "net/url" - "regexp" "strconv" "strings" "time" "github.com/go-kit/log" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/common/config" "github.com/prometheus/common/model" diff --git a/discovery/puppetdb/puppetdb.go b/discovery/puppetdb/puppetdb.go index c6e93ebe9a..c2fbba0231 100644 --- a/discovery/puppetdb/puppetdb.go +++ b/discovery/puppetdb/puppetdb.go @@ -24,12 +24,12 @@ import ( "net/http" "net/url" "path" - "regexp" "strconv" "strings" "time" "github.com/go-kit/log" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/common/config" "github.com/prometheus/common/model" diff --git a/model/relabel/relabel.go b/model/relabel/relabel.go index db08f3c85f..da21ff9182 100644 --- a/model/relabel/relabel.go +++ b/model/relabel/relabel.go @@ -16,9 +16,9 @@ package relabel import ( "crypto/md5" "fmt" - "regexp" "strings" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/common/model" diff --git a/promql/engine.go b/promql/engine.go index 3eb7503c42..687ad678a7 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -20,7 +20,6 @@ import ( "fmt" "math" "reflect" - "regexp" "runtime" "sort" "strconv" @@ -29,6 +28,7 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" diff --git a/promql/functions.go b/promql/functions.go index 20eafd0e61..423c33f663 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -15,12 +15,12 @@ package promql import ( "math" - "regexp" "sort" "strconv" "strings" "time" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/common/model" diff --git a/promql/query_logger_test.go b/promql/query_logger_test.go index 51c16fdd33..033e012d8c 100644 --- a/promql/query_logger_test.go +++ b/promql/query_logger_test.go @@ -17,9 +17,9 @@ import ( "context" "io/ioutil" "os" - "regexp" "testing" + "github.com/grafana/regexp" "github.com/stretchr/testify/require" ) diff --git a/promql/test.go b/promql/test.go index 1da225a3df..cd734c76d0 100644 --- a/promql/test.go +++ b/promql/test.go @@ -18,11 +18,11 @@ import ( "fmt" "io/ioutil" "math" - "regexp" "strconv" "strings" "time" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" diff --git a/template/template.go b/template/template.go index fa20c0a470..b68a141cfa 100644 --- a/template/template.go +++ b/template/template.go @@ -21,13 +21,13 @@ import ( "math" "net" "net/url" - "regexp" "sort" "strconv" "strings" text_template "text/template" "time" + "github.com/grafana/regexp" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" diff --git a/util/httputil/cors.go b/util/httputil/cors.go index c8bdb3ac35..7e0dac7871 100644 --- a/util/httputil/cors.go +++ b/util/httputil/cors.go @@ -15,7 +15,8 @@ package httputil import ( "net/http" - "regexp" + + "github.com/grafana/regexp" ) var corsHeaders = map[string]string{ diff --git a/util/httputil/cors_test.go b/util/httputil/cors_test.go index 363cde19ad..cfa2400405 100644 --- a/util/httputil/cors_test.go +++ b/util/httputil/cors_test.go @@ -15,9 +15,9 @@ package httputil import ( "net/http" - "regexp" "testing" + "github.com/grafana/regexp" "github.com/stretchr/testify/require" ) diff --git a/util/logging/file_test.go b/util/logging/file_test.go index d49426143d..537a2a713b 100644 --- a/util/logging/file_test.go +++ b/util/logging/file_test.go @@ -16,10 +16,10 @@ package logging import ( "io/ioutil" "os" - "regexp" "strings" "testing" + "github.com/grafana/regexp" "github.com/stretchr/testify/require" ) diff --git a/util/stats/stats_test.go b/util/stats/stats_test.go index 34862f6f36..af0adaaf71 100644 --- a/util/stats/stats_test.go +++ b/util/stats/stats_test.go @@ -15,10 +15,10 @@ package stats import ( "encoding/json" - "regexp" "testing" "time" + "github.com/grafana/regexp" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" diff --git a/util/strutil/strconv.go b/util/strutil/strconv.go index eed0134abd..5d62bac9c9 100644 --- a/util/strutil/strconv.go +++ b/util/strutil/strconv.go @@ -16,7 +16,8 @@ package strutil import ( "fmt" "net/url" - "regexp" + + "github.com/grafana/regexp" ) var invalidLabelCharRE = regexp.MustCompile(`[^a-zA-Z0-9_]`) diff --git a/web/api/v1/api.go b/web/api/v1/api.go index 34375414d1..bd2519f0aa 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -23,7 +23,6 @@ import ( "net/url" "os" "path/filepath" - "regexp" "sort" "strconv" "strings" @@ -32,6 +31,7 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/regexp" jsoniter "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" diff --git a/web/web.go b/web/web.go index b5bff47835..47d76590ec 100644 --- a/web/web.go +++ b/web/web.go @@ -29,7 +29,6 @@ import ( "os" "path" "path/filepath" - "regexp" "runtime" "strconv" "strings" @@ -39,6 +38,7 @@ import ( "github.com/alecthomas/units" "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/regexp" conntrack "github.com/mwitkow/go-conntrack" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus"