Skip to content

Commit 27835d3

Browse files
committed
BUILD/MAJOR: go: upgrade go to 1.23 and client-native
Includes changes to mimetypes in handlers for general storage and raw. Alse removal of unused enum on tcp-request and tcp-response.
1 parent a874eb4 commit 27835d3

25 files changed

+166
-223
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variables:
77
DOCKER_HOST: tcp://docker:2375
88
DOCKER_BASE_IMAGE: $CI_REGISTRY_GO/haproxy-debian
99
BATS_VERSION: v1.4.1
10-
GO_VERSION: "1.22"
10+
GO_VERSION: "1.23"
1111
DOCKER_VERSION: "26.0"
1212

1313
diff:

.golangci.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ linters:
2222
disable:
2323
- dupl
2424
- exhaustive
25-
- exhaustivestruct
2625
- funlen
2726
- gci
2827
- gochecknoglobals
2928
- gocognit
3029
- goconst
3130
- gocyclo
3231
- godot
33-
- goerr113
34-
- gomnd
3532
- lll
3633
- nestif
3734
- nlreturn
@@ -41,18 +38,9 @@ linters:
4138
- paralleltest
4239
- testpackage
4340
- varnamelen
44-
- nosnakecase
4541
- exhaustruct
4642
- nonamedreturns
4743
- forcetypeassert
48-
- golint #deprecated
49-
- varcheck #deprecated
50-
- ifshort #deprecated
51-
- structcheck #deprecated
52-
- maligned #deprecated
53-
- scopelint #deprecated
54-
- interfacer #deprecated
55-
- deadcode #deprecated
5644
- rowserrcheck #rowserrcheck is disabled because of generics
5745
- sqlclosecheck #rowserrcheck is disabled because of generics
5846
- wastedassign #rowserrcheck is disabled because of generics
@@ -71,6 +59,11 @@ linters:
7159
- gocritic
7260
- tagalign
7361
- depguard
62+
- mnd
63+
- gomnd
64+
- err113
65+
- execinquery
66+
- exportloopref
7467

7568
issues:
7669
exclude:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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.57.1
12+
GOLANGCI_LINT_VERSION=1.61.0
1313

1414
all: update clean build
1515

configuration/dataplane_storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (c *Configuration) copyClusterToConfiguration(dapiStorageCluster *storagety
130130
if dapiStorageCluster.ClusterID != nil && !misc.HasOSArg("", "", "") {
131131
c.Cluster.ClusterID.Store(*dapiStorageCluster.ClusterID)
132132
}
133-
if dapiStorageCluster.ClusterLogTargets != nil && len(dapiStorageCluster.ClusterLogTargets) > 0 {
133+
if len(dapiStorageCluster.ClusterLogTargets) > 0 {
134134
c.Cluster.ClusterLogTargets = dapiStorageCluster.ClusterLogTargets
135135
}
136136
}

configuration/map_sync.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,29 +124,29 @@ func equalSomeEntries(fEntries, rEntries models.MapEntries, index ...int) bool {
124124
return false
125125
}
126126

127-
max := 0
127+
var maximum int
128128
switch l := len(rEntries); {
129129
case l > 19:
130130
for i := l - 20; i < l; i++ {
131131
if rEntries[i].Key != fEntries[i].Key || rEntries[i].Value != fEntries[i].Value {
132132
return false
133133
}
134134
}
135-
max = l - 19
135+
maximum = l - 19
136136
case l == 0:
137137
return true
138138
default:
139-
max = l
139+
maximum = l
140140
}
141141

142142
maxRandom := 10
143-
if max < 10 {
144-
maxRandom = max
143+
if maximum < 10 {
144+
maxRandom = maximum
145145
}
146146

147147
for range maxRandom {
148148
// There's no need for strong number generation, here, just need for performance
149-
r := rand.Intn(max)
149+
r := rand.Intn(maximum)
150150
if len(index) > 0 {
151151
r = index[0]
152152
}

configuration/user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,20 @@ func AuthenticateUser(user string, pass string) (interface{}, error) {
176176
if strings.HasPrefix(u.Password, "\"${") && strings.HasSuffix(u.Password, "}\"") {
177177
userPass = os.Getenv(misc.ExtractEnvVar(userPass))
178178
if userPass == "" {
179-
return nil, api_errors.New(401, fmt.Sprintf("%s %s", "can not read password from env variable:", u.Password))
179+
return nil, api_errors.New(401, "%s %s", "can not read password from env variable:", u.Password)
180180
}
181181
}
182182

183183
if u.IsInsecure {
184184
if pass == userPass {
185185
return user, nil
186186
}
187-
return nil, api_errors.New(401, fmt.Sprintf("%s %s", "invalid password:", pass))
187+
return nil, api_errors.New(401, "%s %s", "invalid password:", pass)
188188
}
189189
if checkPassword(pass, userPass) {
190190
return user, nil
191191
}
192-
return nil, api_errors.New(401, fmt.Sprintf("%s %s", "invalid password:", pass))
192+
return nil, api_errors.New(401, "%s %s", "invalid password:", pass)
193193
}
194194

195195
func checkPassword(pass, storedPass string) bool {

configure_data_plane.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import (
5656
"github.com/haproxytech/dataplaneapi/operations"
5757
"github.com/haproxytech/dataplaneapi/operations/discovery"
5858
"github.com/haproxytech/dataplaneapi/operations/specification"
59-
"github.com/haproxytech/dataplaneapi/operations/specification_openapiv3"
59+
"github.com/haproxytech/dataplaneapi/operations/version3"
6060
"github.com/haproxytech/dataplaneapi/rate"
6161
"github.com/haproxytech/dataplaneapi/resilient"
6262
socket_runtime "github.com/haproxytech/dataplaneapi/runtime"
@@ -868,7 +868,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { //nolint:cyclop,m
868868
data.ID = service_discovery.NewServiceDiscoveryUUID()
869869
}
870870
if errSD = service_discovery.ValidateConsulData(data, true); errSD != nil {
871-
log.Fatalf("Error validating Consul instance: " + errSD.Error())
871+
log.Fatal("Error validating Consul instance: " + errSD.Error())
872872
}
873873
if errSD = discovery.AddNode("consul", *data.ID, data); errSD != nil {
874874
log.Warning("Error creating consul instance: " + errSD.Error())
@@ -884,7 +884,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { //nolint:cyclop,m
884884
data.ID = service_discovery.NewServiceDiscoveryUUID()
885885
}
886886
if errSD = service_discovery.ValidateAWSData(data, true); errSD != nil {
887-
log.Fatalf("Error validating AWS instance: " + errSD.Error())
887+
log.Fatal("Error validating AWS instance: " + errSD.Error())
888888
}
889889
if errSD = discovery.AddNode("aws", *data.ID, data); errSD != nil {
890890
log.Warning("Error creating AWS instance: " + errSD.Error())
@@ -917,12 +917,12 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { //nolint:cyclop,m
917917
api.StorageReplaceStorageGeneralFileHandler = &handlers.StorageReplaceStorageGeneralFileHandlerImpl{Client: client, ReloadAgent: ra}
918918

919919
// setup OpenAPI v3 specification handler
920-
api.SpecificationOpenapiv3GetOpenapiv3SpecificationHandler = specification_openapiv3.GetOpenapiv3SpecificationHandlerFunc(func(params specification_openapiv3.GetOpenapiv3SpecificationParams, principal interface{}) middleware.Responder {
920+
api.Version3GetOpenapiv3SpecificationHandler = version3.GetOpenapiv3SpecificationHandlerFunc(func(params version3.GetOpenapiv3SpecificationParams, principal interface{}) middleware.Responder {
921921
v2 := openapi2.T{}
922922
err = v2.UnmarshalJSON(SwaggerJSON)
923923
if err != nil {
924924
e := misc.HandleError(err)
925-
return specification_openapiv3.NewGetOpenapiv3SpecificationDefault(int(*e.Code)).WithPayload(e)
925+
return version3.NewGetOpenapiv3SpecificationDefault(int(*e.Code)).WithPayload(e)
926926
}
927927

928928
// if host is empty(dynamic hosts), server prop is empty,
@@ -936,9 +936,9 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { //nolint:cyclop,m
936936
v3, err = openapi2conv.ToV3(&v2)
937937
if err != nil {
938938
e := misc.HandleError(err)
939-
return specification_openapiv3.NewGetOpenapiv3SpecificationDefault(int(*e.Code)).WithPayload(e)
939+
return version3.NewGetOpenapiv3SpecificationDefault(int(*e.Code)).WithPayload(e)
940940
}
941-
return specification_openapiv3.NewGetOpenapiv3SpecificationOK().WithPayload(v3)
941+
return version3.NewGetOpenapiv3SpecificationOK().WithPayload(v3)
942942
})
943943

944944
// TODO: do we need a ReloadAgent for SPOE
@@ -1217,10 +1217,10 @@ func handleSignals(ctx context.Context, cancel context.CancelFunc, sigs chan os.
12171217
func reloadConfigurationFile(client client_native.HAProxyClient, haproxyOptions dataplaneapi_config.HAProxyConfiguration, users *dataplaneapi_config.Users) {
12181218
confClient, err := cn.ConfigureConfigurationClient(haproxyOptions, mWorker)
12191219
if err != nil {
1220-
log.Fatalf(err.Error())
1220+
log.Fatal(err.Error())
12211221
}
12221222
if err := users.Init(); err != nil {
1223-
log.Fatalf(err.Error())
1223+
log.Fatal(err.Error())
12241224
}
12251225
log.Info("Rereading Configuration Files")
12261226
clientMutex.Lock()

discovery/consul_service_discovery_instance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (c *consulInstance) validateHealthChecks(node *serviceEntry) bool {
211211
}
212212

213213
func (c *consulInstance) validateHealthChecksAny(node *serviceEntry) bool {
214-
if node.Checks == nil || len(node.Checks) == 0 {
214+
if len(node.Checks) == 0 {
215215
return false
216216
}
217217

@@ -224,7 +224,7 @@ func (c *consulInstance) validateHealthChecksAny(node *serviceEntry) bool {
224224
}
225225

226226
func (c *consulInstance) validateHealthChecksAll(node *serviceEntry) bool {
227-
if node.Checks == nil || len(node.Checks) == 0 {
227+
if len(node.Checks) == 0 {
228228
return false
229229
}
230230

@@ -237,7 +237,7 @@ func (c *consulInstance) validateHealthChecksAll(node *serviceEntry) bool {
237237
}
238238

239239
func (c *consulInstance) validateHealthChecksMin(node *serviceEntry) bool {
240-
if node.Checks == nil || len(node.Checks) == 0 {
240+
if len(node.Checks) == 0 {
241241
return false
242242
}
243243

doc.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)