Skip to content

Commit 31aff3b

Browse files
committed
feat(cmd): remove global name scheme, prevent using lints
1 parent 6dd13a0 commit 31aff3b

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

.golangci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ linters:
4141
- unused
4242
- usestdlibvars
4343
- whitespace
44+
- forbidigo
4445

4546
exclusions:
4647
paths:
@@ -169,6 +170,19 @@ linters:
169170
- float-compare
170171
- go-require
171172
enable-all: true
173+
forbidigo:
174+
analyze-types: true
175+
forbid:
176+
- pattern: ^.*model\.NameValidationScheme$
177+
pkg: ^github.com/prometheus/common/model$
178+
msg: it is deprecated. Use model/validation.NamingScheme instead.
179+
- pattern: ^.*model\.LabelName\.IsValid$
180+
pkg: ^github.com/prometheus/common/model$
181+
msg: it depends on model.NameValidationScheme. Use model/validation.NamingScheme instead.
182+
- pattern: ^.*model\.IsValidMetricName$
183+
pkg: ^github.com/prometheus/common/model$
184+
msg: it depends on model.NameValidationScheme. Use model/validation.NamingScheme instead.
185+
172186

173187
output:
174188
show-stats: false

cmd/prometheus/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ var (
141141
)
142142

143143
func init() {
144-
// This can be removed when the legacy global mode is fully deprecated.
145-
//nolint:staticcheck
146-
model.NameValidationScheme = model.UTF8Validation
147-
148144
prometheus.MustRegister(versioncollector.NewCollector(strings.ReplaceAll(appName, "-", "_")))
149145

150146
var err error

cmd/prometheus/main_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ import (
4646
"github.com/prometheus/prometheus/util/testutil"
4747
)
4848

49-
func init() {
50-
// This can be removed when the legacy global mode is fully deprecated.
51-
//nolint:staticcheck
52-
model.NameValidationScheme = model.UTF8Validation
53-
}
54-
5549
const startupTime = 10 * time.Second
5650

5751
var (

cmd/promtool/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ import (
6363

6464
var promqlEnableDelayedNameRemoval = false
6565

66-
func init() {
67-
// This can be removed when the legacy global mode is fully deprecated.
68-
//nolint:staticcheck
69-
model.NameValidationScheme = model.UTF8Validation
70-
}
71-
7266
const (
7367
successExitCode = 0
7468
failureExitCode = 1

cmd/promtool/main_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ import (
3939
"github.com/prometheus/prometheus/promql/promqltest"
4040
)
4141

42-
func init() {
43-
// This can be removed when the legacy global mode is fully deprecated.
44-
//nolint:staticcheck
45-
model.NameValidationScheme = model.UTF8Validation
46-
}
47-
4842
var promtoolPath = os.Args[0]
4943

5044
func TestMain(m *testing.M) {

0 commit comments

Comments
 (0)