Skip to content

Commit edb9a4d

Browse files
authored
Merge branch 'main' into rorymalcolm/incidentio-notifier
2 parents 0d86b5b + d563660 commit edb9a4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+548
-398
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
- name: Checkout repository
2727
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2828
- name: Install Go
29-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
29+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
3030
with:
3131
go-version: 1.24.x
3232
- name: Install snmp_exporter/generator dependencies
3333
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
3434
if: github.repository == 'prometheus/snmp_exporter'
3535
- name: Lint
36-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
36+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
3737
with:
3838
args: --verbose
39-
version: v1.64.6
39+
version: v2.3.0

.golangci.yml

Lines changed: 83 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,96 @@
1-
output:
2-
sort-results: true
3-
1+
version: "2"
42
linters:
53
enable:
64
- depguard
75
- errorlint
86
- godot
9-
- gofumpt
10-
- goimports
117
- misspell
128
- revive
13-
- testifylint
149
- sloglint
15-
10+
- testifylint
11+
settings:
12+
depguard:
13+
rules:
14+
main:
15+
deny:
16+
- pkg: sync/atomic
17+
desc: "Use go.uber.org/atomic instead of sync/atomic"
18+
- pkg: github.com/stretchr/testify/assert
19+
desc: "Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert"
20+
- pkg: github.com/go-kit/kit/log
21+
desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
22+
- pkg: github.com/pkg/errors
23+
desc: "Use errors or fmt instead of github.com/pkg/errors"
24+
errcheck:
25+
exclude-functions:
26+
# Don't flag lines such as "io.Copy(io.Discard, resp.Body)".
27+
- io.Copy
28+
# The next two are used in HTTP handlers, any error is handled by the server itself.
29+
- io.WriteString
30+
- (net/http.ResponseWriter).Write
31+
# No need to check for errors on server's shutdown.
32+
- (*net/http.Server).Shutdown
33+
# Never check for rollback errors as Rollback() is called when a previous error was detected.
34+
- (github.com/prometheus/prometheus/storage.Appender).Rollback
35+
godot:
36+
scope: toplevel
37+
exclude:
38+
- "^ ?This file is safe to edit"
39+
- "^ ?scheme value"
40+
period: true
41+
capital: true
42+
revive:
43+
rules:
44+
- name: blank-imports
45+
- name: context-as-argument
46+
- name: error-naming
47+
- name: error-return
48+
- name: error-strings
49+
- name: errorf
50+
- name: exported
51+
arguments:
52+
- disableStutteringCheck
53+
- name: if-return
54+
- name: increment-decrement
55+
- name: indent-error-flow
56+
- name: package-comments
57+
- name: range
58+
- name: receiver-naming
59+
- name: time-naming
60+
- name: unexported-return
61+
- name: var-declaration
62+
- name: var-naming
63+
testifylint:
64+
disable:
65+
- float-compare
66+
- go-require
67+
enable-all: true
68+
exclusions:
69+
presets:
70+
- comments
71+
- common-false-positives
72+
- legacy
73+
- std-error-handling
74+
paths:
75+
# Skip autogenerated files.
76+
- ^.*\.(pb|y)\.go$
77+
rules:
78+
- linters:
79+
- errcheck
80+
path: _test.go
81+
warn-unused: true
1682
issues:
1783
max-issues-per-linter: 0
1884
max-same-issues: 0
19-
exclude-rules:
20-
- path: _test.go
21-
linters:
22-
- errcheck
23-
exclude-files:
24-
# Skip autogenerated files.
25-
- ^.*\.(pb|y)\.go$
26-
2785
run:
2886
timeout: 5m
29-
30-
linters-settings:
31-
depguard:
32-
rules:
33-
main:
34-
deny:
35-
- pkg: sync/atomic
36-
desc: "Use go.uber.org/atomic instead of sync/atomic"
37-
- pkg: github.com/stretchr/testify/assert
38-
desc: "Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert"
39-
- pkg: github.com/go-kit/kit/log
40-
desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
41-
- pkg: github.com/pkg/errors
42-
desc: "Use errors or fmt instead of github.com/pkg/errors"
43-
errcheck:
44-
exclude-functions:
45-
# Don't flag lines such as "io.Copy(io.Discard, resp.Body)".
46-
- io.Copy
47-
# The next two are used in HTTP handlers, any error is handled by the server itself.
48-
- io.WriteString
49-
- (net/http.ResponseWriter).Write
50-
# No need to check for errors on server's shutdown.
51-
- (*net/http.Server).Shutdown
52-
# Never check for rollback errors as Rollback() is called when a previous error was detected.
53-
- (github.com/prometheus/prometheus/storage.Appender).Rollback
54-
godot:
55-
scope: toplevel
56-
exclude:
57-
- "^ ?This file is safe to edit"
58-
- "^ ?scheme value"
59-
period: true
60-
capital: true
61-
goimports:
62-
local-prefixes: github.com/prometheus/alertmanager
63-
gofumpt:
64-
extra-rules: true
65-
revive:
66-
rules:
67-
- name: exported
68-
arguments: ["disableStutteringCheck"]
69-
- name: blank-imports
70-
- name: context-as-argument
71-
- name: error-return
72-
- name: error-strings
73-
- name: error-naming
74-
- name: if-return
75-
- name: increment-decrement
76-
- name: var-naming
77-
- name: var-declaration
78-
- name: package-comments
79-
- name: range
80-
- name: receiver-naming
81-
- name: time-naming
82-
- name: unexported-return
83-
- name: indent-error-flow
84-
- name: errorf
85-
testifylint:
86-
disable:
87-
- float-compare
88-
- go-require
89-
enable:
90-
- bool-compare
91-
- compares
92-
- empty
93-
- error-is-as
94-
- error-nil
95-
- expected-actual
96-
- len
97-
- require-error
98-
- suite-dont-use-pkg
99-
- suite-extra-assert-call
87+
formatters:
88+
enable:
89+
- gofumpt
90+
- goimports
91+
settings:
92+
gofumpt:
93+
extra-rules: true
94+
goimports:
95+
local-prefixes:
96+
- github.com/prometheus/alertmanager

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ COPY .build/${OS}-${ARCH}/alertmanager /bin/alertmanager
1111
COPY examples/ha/alertmanager.yml /etc/alertmanager/alertmanager.yml
1212

1313
RUN mkdir -p /alertmanager && \
14-
chown -R nobody:nobody /etc/alertmanager /alertmanager
14+
chown -R nobody:nobody /etc/alertmanager /alertmanager && \
15+
chmod -R g+w /alertmanager
1516

1617
USER nobody
1718
EXPOSE 9093

Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
6161
SKIP_GOLANGCI_LINT :=
6262
GOLANGCI_LINT :=
6363
GOLANGCI_LINT_OPTS ?=
64-
GOLANGCI_LINT_VERSION ?= v1.64.6
64+
GOLANGCI_LINT_VERSION ?= v2.3.0
6565
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
6666
# windows isn't included here because of the path separator being different.
6767
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))

api/v2/api.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,16 +565,16 @@ func SortSilences(sils open_api_models.GettableSilences) {
565565
}
566566
switch state1 {
567567
case types.SilenceStateActive:
568-
endsAt1 := time.Time(*sils[i].Silence.EndsAt)
569-
endsAt2 := time.Time(*sils[j].Silence.EndsAt)
568+
endsAt1 := time.Time(*sils[i].EndsAt)
569+
endsAt2 := time.Time(*sils[j].EndsAt)
570570
return endsAt1.Before(endsAt2)
571571
case types.SilenceStatePending:
572-
startsAt1 := time.Time(*sils[i].Silence.StartsAt)
573-
startsAt2 := time.Time(*sils[j].Silence.StartsAt)
572+
startsAt1 := time.Time(*sils[i].StartsAt)
573+
startsAt2 := time.Time(*sils[j].StartsAt)
574574
return startsAt1.Before(startsAt2)
575575
case types.SilenceStateExpired:
576-
endsAt1 := time.Time(*sils[i].Silence.EndsAt)
577-
endsAt2 := time.Time(*sils[j].Silence.EndsAt)
576+
endsAt1 := time.Time(*sils[i].EndsAt)
577+
endsAt2 := time.Time(*sils[j].EndsAt)
578578
return endsAt1.After(endsAt2)
579579
}
580580
return false

cli/format/format_extended.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func (formatter *ExtendedFormatter) FormatSilences(silences []models.GettableSil
4848
"%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n",
4949
*silence.ID,
5050
extendedFormatMatchers(silence.Matchers),
51-
FormatDate(*silence.Silence.StartsAt),
52-
FormatDate(*silence.Silence.EndsAt),
51+
FormatDate(*silence.StartsAt),
52+
FormatDate(*silence.EndsAt),
5353
FormatDate(*silence.UpdatedAt),
5454
*silence.CreatedBy,
5555
*silence.Comment,

cli/format/sort.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type ByEndAt []models.GettableSilence
2727
func (s ByEndAt) Len() int { return len(s) }
2828
func (s ByEndAt) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
2929
func (s ByEndAt) Less(i, j int) bool {
30-
return time.Time(*s[i].Silence.EndsAt).Before(time.Time(*s[j].Silence.EndsAt))
30+
return time.Time(*s[i].Silence.EndsAt).Before(time.Time(*s[j].EndsAt))
3131
}
3232

3333
type ByStartsAt []*models.GettableAlert

cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var (
5252
func initMatchersCompat(_ *kingpin.ParseContext) error {
5353
promslogConfig := &promslog.Config{Writer: os.Stdout}
5454
if verbose {
55-
promslogConfig.Level = &promslog.AllowedLevel{}
55+
promslogConfig.Level = promslog.NewLevel()
5656
_ = promslogConfig.Level.Set("debug")
5757
}
5858
logger := promslog.New(promslogConfig)

cluster/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,11 @@ func (p *Peer) Status() string {
610610

611611
// Info returns a JSON-serializable dump of cluster state.
612612
// Useful for debug.
613-
func (p *Peer) Info() map[string]interface{} {
613+
func (p *Peer) Info() map[string]any {
614614
p.mtx.RLock()
615615
defer p.mtx.RUnlock()
616616

617-
return map[string]interface{}{
617+
return map[string]any{
618618
"self": p.mlist.LocalNode(),
619619
"members": p.mlist.Members(),
620620
}

cluster/cluster_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func testJoinLeave(t *testing.T) {
105105
p2.Leave(0 * time.Second)
106106
require.Equal(t, 1, p.ClusterSize())
107107
require.Len(t, p.failedPeers, 1)
108-
require.Equal(t, p2.Self().Address(), p.peers[p2.Self().Address()].Node.Address())
108+
require.Equal(t, p2.Self().Address(), p.peers[p2.Self().Address()].Address())
109109
require.Equal(t, p2.Name(), p.failedPeers[0].Name)
110110
}
111111

@@ -341,6 +341,6 @@ func testTLSConnection(t *testing.T) {
341341
p2.Leave(0 * time.Second)
342342
require.Equal(t, 1, p1.ClusterSize())
343343
require.Len(t, p1.failedPeers, 1)
344-
require.Equal(t, p2.Self().Address(), p1.peers[p2.Self().Address()].Node.Address())
344+
require.Equal(t, p2.Self().Address(), p1.peers[p2.Self().Address()].Address())
345345
require.Equal(t, p2.Name(), p1.failedPeers[0].Name)
346346
}

0 commit comments

Comments
 (0)