Skip to content

Commit 15aa01e

Browse files
committed
BUILD/MEDIUM: go: increase Go version to 1.23
1 parent ce7d72f commit 15aa01e

33 files changed

+67
-64
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ variables:
1111
KIND: v0.21.0
1212
DOCKER_HOST: tcp://docker:2375
1313
DOCKER_DRIVER: overlay2
14-
GO_VERSION: "1.22"
15-
DOCKER_VERSION: "24.0.6"
14+
GO_VERSION: "1.23"
15+
DOCKER_VERSION: "26.0"
1616
diff:
1717
stage: diff
1818
rules:
@@ -105,7 +105,7 @@ unit-tests:
105105
- if: $CI_PIPELINE_SOURCE == 'push'
106106
stage: unit-tests
107107
image:
108-
name: $CI_REGISTRY_GO/haproxy-alpine:2.7-go$GO_VERSION
108+
name: $CI_REGISTRY_GO/haproxy-alpine:3.0-go$GO_VERSION
109109
entrypoint: [""]
110110
tags:
111111
- go

.golangci.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
linters-settings:
22
govet:
3-
check-shadowing: true
3+
shadow: true
44
gocyclo:
55
min-complexity: 42
66
cyclop:
77
max-complexity: 42
8-
maligned:
9-
suggest-new: true
108
dupl:
119
threshold: 200
1210
revive:
@@ -20,15 +18,13 @@ linters:
2018
- ireturn
2119
- dupl
2220
- exhaustive
23-
- exhaustivestruct
2421
- funlen
2522
- gci
2623
- gochecknoglobals
2724
- gocognit
2825
- goconst
2926
- gocyclo
3027
- godot
31-
- goerr113
3228
- gomnd
3329
- lll
3430
- nestif
@@ -39,19 +35,19 @@ linters:
3935
- paralleltest
4036
- testpackage
4137
- varnamelen
42-
- nosnakecase
4338
- exhaustruct
4439
- nonamedreturns
4540
- forcetypeassert
46-
- golint #deprecated
47-
- varcheck #deprecated
48-
- ifshort #deprecated
49-
- structcheck #deprecated
50-
- maligned #deprecated
51-
- scopelint #deprecated
52-
- interfacer #deprecated
53-
- deadcode #deprecated
5441
- depguard
42+
- mnd
43+
- inamedparam
44+
- err113 # maybe tmp disable
45+
- asasalint
46+
- exportloopref # deprecated
47+
- execinquery # deprecated
48+
- tagliatelle
49+
- testifylint
50+
- typecheck
5551
issues:
5652
exclude:
5753
- "tag is not aligned, should be:" # this is harder to read

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PROJECT_PATH=${PWD}
22
TARGETPLATFORM?=linux/amd64
33
GOOS?=linux
44
GOARCH?=amd64
5-
GOLANGCI_LINT_VERSION=1.54.2
5+
GOLANGCI_LINT_VERSION=1.61.0
66

77
.PHONY: test
88
test:

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.22-alpine AS builder
15+
FROM golang:1.23-alpine AS builder
1616

1717
RUN apk --no-cache add git openssh
1818

build/Dockerfile.pebble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.22-alpine AS builder
15+
FROM golang:1.23-alpine AS builder
1616

1717
RUN apk --no-cache add git openssh
1818

deploy/tests/e2e/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (t *Test) GetK8sVersion() (major, minor int, err error) {
131131
if err != nil {
132132
return 0, 0, err
133133
}
134-
config, err := clientcmd.BuildConfigFromFlags("", fmt.Sprintf("%s/.kube/config", home))
134+
config, err := clientcmd.BuildConfigFromFlags("", home+"/.kube/config")
135135
if err != nil {
136136
return 0, 0, err
137137
}

deploy/tests/images/http-echo/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-alpine AS builder
1+
FROM golang:1.23-alpine AS builder
22

33
COPY *.go /src/
44
COPY go.mod /src/go.mod

deploy/tests/images/http-echo/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module echo-http
22

3-
go 1.22
3+
go 1.23

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/haproxytech/kubernetes-ingress
22

3-
go 1.22.0
3+
go 1.23
44

55
require (
66
github.com/Masterminds/semver/v3 v3.2.1

pkg/annotations/service/checkHTTP.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package service
22

33
import (
4-
"fmt"
4+
"errors"
55
"strings"
66

77
"github.com/haproxytech/client-native/v5/models"
@@ -34,7 +34,7 @@ func (a *CheckHTTP) Process(k store.K8s, annotations ...map[string]string) error
3434
checkHTTPParams := strings.Fields(strings.TrimSpace(input))
3535
switch len(checkHTTPParams) {
3636
case 0:
37-
return fmt.Errorf("httpchk option: incorrect number of params")
37+
return errors.New("httpchk option: incorrect number of params")
3838
case 1:
3939
params = &models.HttpchkParams{
4040
URI: checkHTTPParams[0],

pkg/annotations/service/loadbalance.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package service
22

33
import (
4+
"errors"
45
"fmt"
56
"regexp"
67
"strconv"
@@ -49,7 +50,7 @@ func getParamsFromInput(value string) (*models.Balance, error) {
4950
balance := &models.Balance{}
5051
tokens := strings.Split(value, " ")
5152
if len(tokens) == 0 {
52-
return nil, fmt.Errorf("missing algorithm name")
53+
return nil, errors.New("missing algorithm name")
5354
}
5455

5556
reg := regexp.MustCompile(`(\(|\))`)

pkg/gateways/gateways.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func (gm GatewayManagerImpl) isTCPRouteAllowedByListener(listener store.Listener
549549
return routeNamespace != gatewayNamespace
550550
}
551551

552-
gkAllowed := listener.AllowedRoutes.Kinds == nil || len(listener.AllowedRoutes.Kinds) == 0
552+
gkAllowed := len(listener.AllowedRoutes.Kinds) == 0
553553
for _, kind := range listener.AllowedRoutes.Kinds {
554554
if (kind.Group != nil && *kind.Group != v1alpha2.GroupName) || kind.Kind != K8S_TCPROUTE_KIND {
555555
continue

pkg/gateways/updates.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ func (statusMgr *StatusManagerImpl) UpdateStatusTCPRoutes(routesStatusRecords []
175175
}
176176

177177
for _, parentStatusRecord := range tcprouteStatusRecord.parentsStatusesRecords {
178-
parentStatusRecord := parentStatusRecord
179178
conditions := []metav1.Condition{}
180179
routeParentStatus := v1alpha2.RouteParentStatus{
181180
ControllerName: v1alpha2.GatewayController(statusMgr.gatewayControllerName),

pkg/handler/https.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (handler HTTPS) enableSSLPassthrough(h haproxy.HAProxy) (err error) {
225225
}),
226226
h.BackendSwitchingRuleCreate(h.FrontSSL, models.BackendSwitchingRule{
227227
Index: utils.PtrInt64(0),
228-
Name: fmt.Sprintf("%%[var(txn.sni_match),field(1,.)]"),
228+
Name: fmt.Sprintf("%%[var(txn.sni_match),field(1,.)]"), //nolint:perfsprint
229229
}),
230230
handler.toggleSSLPassthrough(true, h))
231231
return errors.Result()

pkg/handler/tcp-services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (handler TCPServices) Update(k store.K8s, h haproxy.HAProxy, a annotations.
4040
if port == "log-format-tcp" {
4141
continue
4242
}
43-
frontendName := fmt.Sprintf("tcp-%s", port)
43+
frontendName := "tcp-" + port
4444
p, err = handler.parseTCPService(k, tcpSvcAnn)
4545
if err != nil {
4646
logger.Error(err)

pkg/haproxy/api/backend.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package api
22

33
import (
4-
"fmt"
4+
"errors"
55

66
"github.com/haproxytech/client-native/v5/models"
77
"github.com/haproxytech/config-parser/v5/types"
@@ -197,7 +197,7 @@ func (c *clientNative) BackendSwitchingRuleDeleteAll(frontend string) (err error
197197
if err != nil {
198198
return
199199
}
200-
for i := 0; i < len(switchingRules); i++ {
200+
for range switchingRules {
201201
if err = configuration.DeleteBackendSwitchingRule(0, frontend, c.activeTransaction, 0); err != nil {
202202
break
203203
}
@@ -232,7 +232,7 @@ func (c *clientNative) BackendServersGet(backendName string) (models.Servers, er
232232
func (c *clientNative) RefreshBackends() (deleted []string, err error) {
233233
backends, errAPI := c.BackendsGet()
234234
if errAPI != nil {
235-
err = fmt.Errorf("unable to get configured backends")
235+
err = errors.New("unable to get configured backends")
236236
return
237237
}
238238
for _, backend := range backends {

pkg/haproxy/api/runtime.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
1414
)
1515

16-
var ErrMapNotFound = fmt.Errorf("map not found")
16+
var ErrMapNotFound = errors.New("map not found")
1717

1818
type RuntimeServerData struct {
1919
BackendName string
@@ -98,7 +98,7 @@ func (c *clientNative) runRaw(runtime runtime.Runtime, sb strings.Builder, backe
9898
if err != nil {
9999
return err
100100
}
101-
for i := 0; i < len(result); i++ {
101+
for i := range result {
102102
if len(result[i]) > 5 {
103103
switch result[i][1:5] {
104104
case "[3]:", "[2]:", "[1]:", "[0]:":
@@ -130,7 +130,7 @@ func (c *clientNative) SetMapContent(mapFile string, payload []string) error {
130130
err = fmt.Errorf("error getting map path: %w", err)
131131
return err
132132
}
133-
for i := 0; i < len(payload); i++ {
133+
for i := range payload {
134134
_, err = runtime.ExecuteRaw(fmt.Sprintf("add map @%s %s <<\n%s\n", mapVer, mapPath, payload[i]))
135135
if err != nil {
136136
err = fmt.Errorf("error loading map payload: %w", err)

pkg/haproxy/certs/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ type SecretCtx struct {
7070
func New(envParam Env) (Certificates, error) { //nolint:ireturn
7171
env = envParam
7272
if env.FrontendDir == "" {
73-
return nil, fmt.Errorf("empty name for Frontend Cert Directory")
73+
return nil, errors.New("empty name for Frontend Cert Directory")
7474
}
7575
if env.BackendDir == "" {
76-
return nil, fmt.Errorf("empty name for Backend Cert Directory")
76+
return nil, errors.New("empty name for Backend Cert Directory")
7777
}
7878
if env.CaDir == "" {
79-
return nil, fmt.Errorf("empty name for CA Cert Directory")
79+
return nil, errors.New("empty name for CA Cert Directory")
8080
}
8181
return &certs{
8282
frontend: make(map[string]*cert),
@@ -211,15 +211,15 @@ func writeSecret(secret *store.Secret, c *cert, privateKeyNull bool) (err error)
211211
if !crtOk {
212212
return fmt.Errorf("certificate missing in %s/%s", secret.Namespace, secret.Name)
213213
}
214-
c.path = fmt.Sprintf("%s.pem", c.path)
214+
c.path += ".pem"
215215
return writeCert(c.path, []byte(""), crtValue)
216216
}
217217
for _, k := range []string{"tls", "rsa", "ecdsa", "dsa"} {
218218
keyValue, keyOk = secret.Data[k+".key"]
219219
crtValue, crtOk = secret.Data[k+".crt"]
220220
if keyOk && crtOk {
221221
pemOk = true
222-
certPath = fmt.Sprintf("%s.pem", c.path)
222+
certPath = c.path + ".pem"
223223
if k != "tls" {
224224
// HAProxy "cert bundle"
225225
certPath = fmt.Sprintf("%s.%s", certPath, k)

pkg/haproxy/env/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package env
1616

1717
import (
18+
"errors"
1819
"fmt"
1920
"os"
2021
"path/filepath"
@@ -62,7 +63,7 @@ func (env *Env) Init(osArgs utils.OSArgs) (err error) {
6263
}
6364
for _, dir := range []string{env.CfgDir, env.RuntimeDir, env.StateDir} {
6465
if dir == "" {
65-
return fmt.Errorf("failed to init controller config: missing config directories")
66+
return errors.New("failed to init controller config: missing config directories")
6667
}
6768
}
6869
// Binary and main files

pkg/haproxy/maps/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package maps
1616

1717
import (
1818
"errors"
19-
"fmt"
2019
"hash/fnv"
2120
"os"
2221
"path"
@@ -82,7 +81,7 @@ func (mf *mapFile) getContent() (result []string, hash uint64) {
8281

8382
func New(dir string, persistentMaps []Name) (Maps, error) { //nolint:ireturn
8483
if dir == "" {
85-
return nil, fmt.Errorf("empty name for map directory")
84+
return nil, errors.New("empty name for map directory")
8685
}
8786
mapDir = dir
8887
var maps mapFiles = make(map[Name]*mapFile, len(persistentMaps))

pkg/haproxy/process/direct-control.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (d *directControl) Service(action string) (err error) {
2929
// hold information about a running Master HAproxy process
3030
process, processErr := haproxyProcess(d.Env.PIDFile)
3131

32-
masterSocketArg := fmt.Sprintf("%s,level,admin", d.Env.MasterSocket)
32+
masterSocketArg := d.Env.MasterSocket + ",level,admin"
3333

3434
//nolint:gosec //checks on HAProxyBinary should be done in configuration module.
3535
switch action {

pkg/haproxy/rules/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rules
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67

78
"github.com/haproxytech/client-native/v5/models"
@@ -73,7 +74,7 @@ func (rules *List) Add(rule Rule) {
7374

7475
func (r SectionRules) AddRule(frontend string, rule Rule, ingressRule bool) error {
7576
if rule == nil || frontend == "" {
76-
return fmt.Errorf("invalid params")
77+
return errors.New("invalid params")
7778
}
7879
// Create frontend ruleSet
7980
ftRuleSet, ok := r[frontend]

pkg/haproxy/rules/reqAcceptContent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package rules
22

33
import (
4-
"fmt"
4+
"errors"
55

66
"github.com/haproxytech/client-native/v5/models"
77

@@ -17,7 +17,7 @@ func (r ReqAcceptContent) GetType() Type {
1717

1818
func (r ReqAcceptContent) Create(client api.HAProxyClient, frontend *models.Frontend, ingressACL string) error {
1919
if frontend.Mode == "http" {
20-
return fmt.Errorf("tcp accept-content rule is only available in TCP frontends")
20+
return errors.New("tcp accept-content rule is only available in TCP frontends")
2121
}
2222
tcpRule := models.TCPRequestRule{
2323
Index: utils.PtrInt64(0),

pkg/haproxy/rules/reqInspectDelay.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package rules
22

33
import (
4-
"fmt"
4+
"errors"
55

66
"github.com/haproxytech/client-native/v5/models"
77

@@ -19,7 +19,7 @@ func (r ReqInspectDelay) GetType() Type {
1919

2020
func (r ReqInspectDelay) Create(client api.HAProxyClient, frontend *models.Frontend, ingressACL string) error {
2121
if frontend.Mode == "http" {
22-
return fmt.Errorf("tcp inspect-delay rule is only available in TCP frontends")
22+
return errors.New("tcp inspect-delay rule is only available in TCP frontends")
2323
}
2424
tcpRule := models.TCPRequestRule{
2525
Type: "inspect-delay",

0 commit comments

Comments
 (0)