Skip to content

Commit dc162ba

Browse files
committed
BUILD/MEDIUM: golang: upgrade go to 1.25 and linter to 2.8.0
1 parent d55eaf8 commit dc162ba

File tree

126 files changed

+863
-855
lines changed

Some content is hidden

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

126 files changed

+863
-855
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ variables:
99
DOCKER_HOST: tcp://docker:2375
1010
DOCKER_BASE_IMAGE: $CI_REGISTRY_GO/haproxy-debian
1111
BATS_VERSION: v1.10.0
12-
GO_VERSION: "1.24"
12+
GO_VERSION: "1.25"
1313
DOCKER_VERSION: "26.0"
1414

1515
pipelines-check:

.golangci.yml

Lines changed: 88 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,104 @@
1-
linters-settings:
2-
golint:
3-
min-confidence: 0
4-
gocyclo:
5-
min-complexity: 42
6-
cyclop:
7-
max-complexity: 42
8-
maligned:
9-
suggest-new: true
10-
dupl:
11-
threshold: 200
12-
goconst:
13-
min-len: 2
14-
min-occurrences: 2
15-
revive:
16-
rules:
17-
- name: var-naming
18-
severity: warning
19-
disabled: true
1+
version: "2"
202
linters:
21-
enable-all: true
3+
default: all
224
disable:
5+
- containedctx
6+
- contextcheck
7+
- depguard
238
- dupl
9+
- err113
10+
- errcheck
11+
- errorlint
2412
- exhaustive
13+
- exhaustruct
14+
- forbidigo
15+
- forcetypeassert
16+
- funcorder
2517
- funlen
26-
- gci
2718
- gochecknoglobals
2819
- gocognit
2920
- goconst
21+
- gocritic
3022
- gocyclo
23+
- godoclint
3124
- godot
25+
- godox
26+
- ireturn
3227
- lll
28+
- mnd
29+
- nakedret
3330
- nestif
3431
- nlreturn
35-
- wrapcheck
36-
- wsl
37-
- nakedret
38-
- paralleltest
39-
- testpackage
40-
- varnamelen
41-
- exhaustruct
42-
- nonamedreturns
43-
- forcetypeassert
44-
- rowserrcheck #rowserrcheck is disabled because of generics
45-
- sqlclosecheck #rowserrcheck is disabled because of generics
46-
- wastedassign #rowserrcheck is disabled because of generics
47-
- ireturn
48-
- tagliatelle
4932
- noctx
50-
- errorlint
51-
- contextcheck
52-
- godox
53-
- containedctx
54-
- unused
55-
- unparam
33+
- noinlineerr
34+
- nonamedreturns
35+
- paralleltest
5636
- prealloc
57-
- forbidigo
58-
- errcheck
59-
- gocritic
60-
- tagalign
61-
- depguard
62-
- mnd
63-
- err113
64-
- tenv # deprecated
6537
- recvcheck
66-
67-
issues:
68-
exclude:
69-
# bugs of typecheck linter
70-
- "undeclared name: `shellquote`"
71-
- 'github.com/kballard/go-shellquote" imported but not used'
72-
- 'github.com/haproxytech/client-native/v6/config-parser/types" imported but not used'
73-
exclude-rules:
74-
- linters:
75-
- staticcheck
76-
text: "duplicate struct tag"
77-
- linters:
78-
- gosec
79-
text: "G[501]"
80-
- linters:
81-
- gosec
82-
text: "G[404]"
83-
exclude-dirs:
84-
- test
38+
- rowserrcheck
39+
- sqlclosecheck
40+
- tagalign
41+
- tagliatelle
42+
- testpackage
43+
- unparam
44+
- unused
45+
- varnamelen
46+
- wastedassign
47+
- wrapcheck
48+
- wsl
49+
- wsl_v5
50+
settings:
51+
cyclop:
52+
max-complexity: 42
53+
dupl:
54+
threshold: 200
55+
goconst:
56+
min-len: 2
57+
min-occurrences: 2
58+
gocyclo:
59+
min-complexity: 42
60+
revive:
61+
rules:
62+
- name: var-naming
63+
severity: warning
64+
disabled: true
65+
exclusions:
66+
generated: lax
67+
presets:
68+
- comments
69+
- common-false-positives
70+
- legacy
71+
- std-error-handling
72+
rules:
73+
- linters:
74+
- staticcheck
75+
text: duplicate struct tag
76+
- linters:
77+
- gosec
78+
text: G[501]
79+
- linters:
80+
- gosec
81+
text: G[404]
82+
- path: (.+)\.go$
83+
text: 'undeclared name: `shellquote`'
84+
- path: (.+)\.go$
85+
text: github.com/kballard/go-shellquote" imported but not used
86+
- path: (.+)\.go$
87+
text: github.com/haproxytech/client-native/v6/config-parser/types" imported but not used
88+
paths:
89+
- test
90+
- third_party$
91+
- builtin$
92+
- examples$
93+
formatters:
94+
enable:
95+
- gofmt
96+
- gofumpt
97+
- goimports
98+
exclusions:
99+
generated: lax
100+
paths:
101+
- test
102+
- third_party$
103+
- builtin$
104+
- examples$

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ GIT_MODIFIED=${GIT_MODIFIED1}${GIT_MODIFIED2}
99
SWAGGER_VERSION=${shell curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $$2}'}
1010
BUILD_DATE=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
1111
CGO_ENABLED?=0
12-
GOLANGCI_LINT_VERSION=1.64.5
13-
CHECK_COMMIT=5.0.4
12+
GOLANGCI_LINT_VERSION=2.8.0
13+
CHECK_COMMIT=5.4.0
1414

1515
all: update clean build
1616

adapters/adapters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func RecoverMiddleware(logger *log.Logger) func(h http.Handler) http.Handler {
8585
if err := recover(); err != nil {
8686
frames := callers()
8787

88-
fields := make(map[string]interface{})
88+
fields := make(map[string]any)
8989
fields["stack_trace"] = frames.String()
9090
logger.WithFieldsf(fields, log.ErrorLevel, "Panic %v", err)
9191

client-native/cn.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ func ConfigureConfigurationClient(haproxyOptions dataplaneapi_config.HAProxyConf
4444

4545
p := confClient.Parser()
4646
comments, err := p.Get(parser.Comments, parser.CommentsSectionName, "#")
47-
insertDisclaimer := false
48-
if err != nil {
49-
insertDisclaimer = true
50-
}
47+
insertDisclaimer := err != nil
5148
data, ok := comments.([]types.Comments)
5249
if !ok {
5350
insertDisclaimer = true

cmd/dataplaneapi/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func startServer(cfg *configuration.Configuration, cancelDebugServer context.Can
227227
api.BasicAuthenticator = func(authentication security.UserPassAuthentication) runtime.Authenticator {
228228
// if mTLS is enabled with backing Certificate Authority, skipping basic authentication
229229
if len(server.TLSCACertificate) > 0 && server.TLSPort > 0 {
230-
return runtime.AuthenticatorFunc(func(i interface{}) (bool, interface{}, error) {
230+
return runtime.AuthenticatorFunc(func(i any) (bool, any, error) {
231231
return true, "", nil
232232
})
233233
}

cmd/gitlab-mr-checker/main.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ type MergeRequest struct {
9090

9191
var baseURL string
9292

93-
const LABEL_COLOR = "#8fbc8f" //nolint:stylecheck
93+
const LABEL_COLOR = "#8fbc8f"
9494

9595
func main() {
9696
_ = godotenv.Overload()
@@ -143,34 +143,41 @@ func main() {
143143

144144
gitlabToken := os.Getenv("GITLAB_TOKEN")
145145

146-
CI_MERGE_REQUEST_IID_STR := os.Getenv("CI_MERGE_REQUEST_IID") //nolint:stylecheck
146+
CI_MERGE_REQUEST_IID_STR := os.Getenv("CI_MERGE_REQUEST_IID")
147147
if CI_MERGE_REQUEST_IID_STR == "" {
148148
slog.Error("CI_MERGE_REQUEST_IID not set")
149149
os.Exit(1)
150150
}
151-
CI_MERGE_REQUEST_IID, err := strconv.Atoi(CI_MERGE_REQUEST_IID_STR) //nolint:stylecheck
151+
CI_MERGE_REQUEST_IID, err := strconv.Atoi(CI_MERGE_REQUEST_IID_STR)
152152
if err != nil {
153153
slog.Error(err.Error())
154154
os.Exit(1)
155155
}
156156

157-
CI_PROJECT_ID := os.Getenv("CI_PROJECT_ID") //nolint:stylecheck
157+
CI_PROJECT_ID := os.Getenv("CI_PROJECT_ID")
158158
if CI_PROJECT_ID == "" {
159159
slog.Error("CI_PROJECT_ID not set")
160160
os.Exit(1)
161161
}
162-
question := `<!-- MR BACKPORT QUESTION -->` + "\n" + "Does this needs backport ? \n| Version | label |\n|:--:|:--:|"
162+
sb := strings.Builder{}
163+
sb.WriteString(`<!-- MR BACKPORT QUESTION -->` + "\n" + "Does this needs backport ? \n| Version | label |\n|:--:|:--:|")
163164
backportLabels := map[string]struct{}{
164165
"backport-ee": {},
165166
}
166167
for _, version := range versions {
167168
ver := strconv.Itoa(int(version.Major())) + "." + strconv.Itoa(int(version.Minor()))
168-
question += "\n" + "| " + ver + " | " + "backport-" + ver + " |"
169+
sb.WriteString("\n")
170+
sb.WriteString("| ")
171+
sb.WriteString(ver)
172+
sb.WriteString(" | ")
173+
sb.WriteString("backport-")
174+
sb.WriteString(ver)
175+
sb.WriteString(" |")
169176
backportLabels["backport-"+ver] = struct{}{}
170177
}
171178
// ee
172-
question += "\n" + "| EE | " + "backport-ee |"
173-
question += "\n\n" + "please add labels for backporting."
179+
sb.WriteString("\n" + "| EE | " + "backport-ee |")
180+
sb.WriteString("\n\n" + "please add labels for backporting.")
174181

175182
mr, err := getMergeRequest(baseURL, gitlabToken, CI_PROJECT_ID, CI_MERGE_REQUEST_IID)
176183
if err != nil {
@@ -199,13 +206,13 @@ func main() {
199206
os.Exit(1)
200207
}
201208
slog.Info("No backport question found, creating one as thread")
202-
startThreadOnMergeRequest(baseURL, gitlabToken, CI_PROJECT_ID, CI_MERGE_REQUEST_IID, question)
209+
startThreadOnMergeRequest(baseURL, gitlabToken, CI_PROJECT_ID, CI_MERGE_REQUEST_IID, sb.String())
203210
}
204211
}
205212

206213
func startThreadOnMergeRequest(baseURL, token, projectID string, mergeRequestIID int, threadBody string) {
207214
client := &http.Client{}
208-
threadData := map[string]interface{}{
215+
threadData := map[string]any{
209216
"body": threadBody,
210217
}
211218
threadDataBytes, err := json.Marshal(threadData)

cmd/govulncheck-report/main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ func main() {
7777

7878
vulnMessage := string(out)
7979
fmt.Println(vulnMessage)
80-
noVuln := false
81-
if !strings.Contains(vulnMessage, "Vulnerability #") {
82-
noVuln = true
83-
}
80+
noVuln := !strings.Contains(vulnMessage, "Vulnerability #")
8481

8582
if currentBranch == "" {
8683
if strings.Contains(vulnMessage, "Vulnerability #") {
@@ -140,7 +137,7 @@ func main() {
140137
func createIssue(baseURL, token, projectID string, title, commentBody string) {
141138
slog.Info("Active issue with title '" + title + "' not found in project " + projectID)
142139
// Create the issue here
143-
issueData := map[string]interface{}{
140+
issueData := map[string]any{
144141
"title": title,
145142
"description": commentBody,
146143
"labels": "bot,critical",
@@ -188,7 +185,7 @@ func closeTheIssue(baseURL, token, projectID string, issueIID int, commentBody s
188185
addCommentToIssue(baseURL, token, projectID, issueIID, commentBody)
189186

190187
client := &http.Client{}
191-
issueData := map[string]interface{}{
188+
issueData := map[string]any{
192189
"state_event": "close",
193190
}
194191
issueDataBytes, err := json.Marshal(issueData)
@@ -230,7 +227,7 @@ func closeTheIssue(baseURL, token, projectID string, issueIID int, commentBody s
230227

231228
func addCommentToIssue(baseURL, token, projectID string, issueIID int, commentBody string) {
232229
client := &http.Client{}
233-
noteData := map[string]interface{}{
230+
noteData := map[string]any{
234231
"body": commentBody,
235232
}
236233
noteDataBytes, err := json.Marshal(noteData)

configuration/bool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (s *AtomicBool) String() string {
4242
return "false"
4343
}
4444

45-
func (s *AtomicBool) UnmarshalYAML(unmarshal func(interface{}) error) error {
45+
func (s *AtomicBool) UnmarshalYAML(unmarshal func(any) error) error {
4646
var buf bool
4747
err := unmarshal(&buf)
4848
if err != nil {
@@ -53,6 +53,6 @@ func (s *AtomicBool) UnmarshalYAML(unmarshal func(interface{}) error) error {
5353
return nil
5454
}
5555

56-
func (s AtomicBool) MarshalYAML() (interface{}, error) {
56+
func (s AtomicBool) MarshalYAML() (any, error) {
5757
return s.Load(), nil
5858
}

configuration/configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (c *Configuration) LoadDataplaneStorageConfig() ([]string, error) {
324324
}
325325

326326
func (c *Configuration) LoadRuntimeVars(swaggerJSON json.RawMessage, host string, port int) error {
327-
var m map[string]interface{}
327+
var m map[string]any
328328
json := jsoniter.ConfigCompatibleWithStandardLibrary
329329
err := json.Unmarshal(swaggerJSON, &m)
330330
if err != nil {

0 commit comments

Comments
 (0)