Skip to content

Commit

Permalink
BUILD/MAJOR: go: upgrade to go 1.23
Browse files Browse the repository at this point in the history
Also upgrade linter, cleanup excluded linters, make linting changes and
upgrade go-swagger to latest version
  • Loading branch information
mjuraga committed Sep 20, 2024
1 parent 35576d3 commit ba9cae2
Show file tree
Hide file tree
Showing 331 changed files with 2,199 additions and 1,261 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
variables:
DOCKER_HOST: tcp://docker:2375
GO_VERSION: "1.22"
DOCKER_VERSION: "24.0.6"
GO_VERSION: "1.23"
DOCKER_VERSION: "26.0"
stages:
- check-commit
- generate
Expand Down
63 changes: 18 additions & 45 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
Expand All @@ -21,59 +19,34 @@ linters-settings:
linters:
enable-all: true
disable:
- golint # deprecated, replaced with revive
- interfacer # deprecated
- maligned # deprecated
- wrapcheck
- nlreturn
- gomnd
- goerr113
- exhaustivestruct
- mnd
- err113
- wsl
- whitespace
- lll
- scopelint
- nestif
- funlen
- paralleltest
- wrapcheck
- godot
- varnamelen
- nlreturn
- ireturn
- ifshort
- thelper
- wastedassign
- goconst
- gci
- exhaustruct
- nonamedreturns
- interfacebloat
- gomnd
- forcetypeassert
- exhaustruct
- dupword
- forcetypeassert # tmp needs to be on
- ifshort # deprecated
- structcheck # deprecated
- deadcode # deprecated
- nosnakecase # deprecated
- varcheck # deprecated
- rowserrcheck # deprecated
- sqlclosecheck # deprecated
- wastedassign # deprecated
- golint # deprecated
- interfacer # deprecated
- maligned # deprecated
- nestif
- lll
- depguard
- funlen
- gci
- goconst
- execinquery
- exportloopref

issues:
exclude-files:
- ".*_test\\.go$"
exclude-dirs:
- test
exclude:
# bugs of typecheck linter
- "undeclared name: `shellquote`"
- "github.com/kballard/go-shellquote\" imported but not used"
- "github.com/haproxytech/client-native/v6/config-parser/types\" imported but not used"
- "unused-parameter: parameter 'comment' seems to be unused"
- "unused-parameter: parameter 'parts' seems to be unused"
- "unused-parameter: parameter 'parserType' seems to be unused"

run:
skip-dirs:
- test
skip-files:
- ".*_test\\.go$"
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PROJECT_PATH=${PWD}
DOCKER_HAPROXY_VERSION?=2.8
SWAGGER_VERSION=v0.30.2
DOCKER_HAPROXY_VERSION?=3.0
SWAGGER_VERSION=v0.31.0
GO_VERSION:=${shell go mod edit -json | jq -r .Go}
GOLANGCI_LINT_VERSION=1.55.2
GOLANGCI_LINT_VERSION=1.61.0

.PHONY: test
test:
Expand Down
3 changes: 1 addition & 2 deletions cmd/kubebuilder_marker_generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
}
}

func generate(fileName string) error { //nolint:gocognit,unparam
func generate(fileName string) error { //nolint:gocognit
f, err := decorator.ParseFile(token.NewFileSet(), fileName, nil, 0)
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -86,7 +86,6 @@ func generate(fileName string) error { //nolint:gocognit,unparam
field.Decorations().Start.Append("// +kubebuilder:validation:Optional")
}
}

}
// if len(field.Names) > 0 {
// log.Printf("Comments before the field %s: %v\n", field.Names[0].Name, comments)
Expand Down
4 changes: 2 additions & 2 deletions cmd/specification/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func expandRef(refValue string, absPath string, prefix string) string {
}
retValStr := buf.String()

indentedRetValStr := ""
indentedLine := ""
var indentedRetValStr string
var indentedLine string
for _, line := range strings.Split(retValStr, "\n") {
if strings.TrimSpace(line) != "" {
indentedLine = prefix + "" + line + "\n"
Expand Down
3 changes: 2 additions & 1 deletion cmd/struct_equal_generator/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
_ "embed"
"errors"
"fmt"
"io/fs"
"log"
Expand Down Expand Up @@ -29,7 +30,7 @@ func (a *Args) Parse() error { //nolint:gocognit
switch {
case val == "-l":
if i+1 >= len(os.Args) {
return fmt.Errorf("missing licence file after -l")
return errors.New("missing licence file after -l")
}
a.LicencePath = os.Args[i+1]
i++
Expand Down
8 changes: 4 additions & 4 deletions cmd/struct_equal_generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ func generate(fileName string, args Args) (string, error) { //nolint:gocognit,ma
switch currType := currSpecType.Type.(type) {
case *ast.StructType:
var fields []Field
needsOptions := false
needsOptionsIndex := false
fields, needsOptions, needsOptionsIndex = getFields(fields, currType, imports)
fields, needsOptions, needsOptionsIndex := getFields(fields, currType, imports)
for _, f := range fields {
if strings.HasPrefix(f.Type, "*") && (f.HasEqualOpt || f.HasEqual) {
needsOptions = true
Expand Down Expand Up @@ -271,7 +269,9 @@ func generate(fileName string, args Args) (string, error) { //nolint:gocognit,ma
return packageName, nil
}

func getFields(fields []Field, node *ast.StructType, imports map[string]string) (fieldsResult []Field, needsOptions, needsOptionsIndex bool) { //nolint:gocognit
func getFields(fields []Field, node *ast.StructType, imports map[string]string) ([]Field, bool, bool) { //nolint:gocognit
var needsOptions bool
var needsOptionsIndex bool
for _, field := range node.Fields.List {
if len(field.Names) > 0 {
res := getTypeString(field.Type, imports)
Expand Down
2 changes: 1 addition & 1 deletion cmd/struct_tags_checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
}
}

func generate(fileName string) error { //nolint:gocognit,unparam
func generate(fileName string) error { //nolint:gocognit
f, err := decorator.ParseFile(token.NewFileSet(), fileName, nil, 0)
if err != nil {
log.Fatal(err)
Expand Down
2 changes: 0 additions & 2 deletions config-parser/params/balance-params.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (b *BalanceURI) String() string {
func (b *BalanceURI) Parse(parts []string) (BalanceParams, error) {
var err error
if len(parts) > 0 {

for i := 0; i < len(parts); i++ {
arg := parts[i]

Expand Down Expand Up @@ -98,7 +97,6 @@ func (u *BalanceURLParam) String() string {
func (u *BalanceURLParam) Parse(parts []string) (BalanceParams, error) {
var err error
if len(parts) > 0 {

for index := 1; index < len(parts); index++ {
arg := parts[index]

Expand Down
2 changes: 1 addition & 1 deletion config-parser/params/server-options.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ type ServerOptionIDValue struct {
// Parse ...
func (b *ServerOptionIDValue) Parse(options []string, currentIndex int) (int, error) {
if currentIndex+1 < len(options) {
if strings.HasPrefix(options[currentIndex], fmt.Sprintf("%s(", b.Name)) {
if strings.HasPrefix(options[currentIndex], b.Name+"(") {
words := strings.Split(options[currentIndex], "(")
if len(words) != 2 {
return 0, &NotEnoughParamsError{}
Expand Down
4 changes: 2 additions & 2 deletions config-parser/parsers/actions/check-connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package actions

import (
"fmt"
stderrors "errors"
"strings"

"github.com/haproxytech/client-native/v6/config-parser/types"
Expand Down Expand Up @@ -50,7 +50,7 @@ func (c *CheckConnect) Parse(parts []string, parserType types.ParserType, commen

// Note: "tcp/http-check connect" with no further params is allowed by HAProxy
if len(parts) < 2 {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}

for i := 2; i < len(parts); i++ {
Expand Down
4 changes: 2 additions & 2 deletions config-parser/parsers/actions/check-expect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package actions

import (
"fmt"
stderrors "errors"
"strconv"
"strings"

Expand Down Expand Up @@ -52,7 +52,7 @@ func (c *CheckExpect) Parse(parts []string, parserType types.ParserType, comment
}

if len(parts) < 3 {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}

var i int
Expand Down
7 changes: 4 additions & 3 deletions config-parser/parsers/actions/check-set-var-fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package actions

import (
stderrors "errors"
"fmt"
"strings"

Expand All @@ -38,7 +39,7 @@ func (f *SetVarFmtCheck) Parse(parts []string, parserType types.ParserType, comm
f.Comment = comment
}
if len(parts) < 3 {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
var data string
var command []string
Expand All @@ -56,11 +57,11 @@ func (f *SetVarFmtCheck) Parse(parts []string, parserType types.ParserType, comm
format := common.Expression{}
err := format.Parse(command)
if err != nil {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
f.Format = format
} else {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
if len(condition) > 1 {
return errors.ErrInvalidData
Expand Down
7 changes: 4 additions & 3 deletions config-parser/parsers/actions/do-resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package actions

import (
stderrors "errors"
"fmt"
"strings"

Expand All @@ -39,7 +40,7 @@ func (f *DoResolve) Parse(parts []string, parserType types.ParserType, comment s
f.Comment = comment
}
if len(parts) < 3 {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
var data string
var command []string
Expand All @@ -56,7 +57,7 @@ func (f *DoResolve) Parse(parts []string, parserType types.ParserType, comment s
d := strings.SplitN(data, ",", 3)

if len(d) < 2 {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}

f.Var = d[0]
Expand All @@ -70,7 +71,7 @@ func (f *DoResolve) Parse(parts []string, parserType types.ParserType, comment s
expr := common.Expression{}
err := expr.Parse(command)
if err != nil {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
f.Expr = expr
}
Expand Down
4 changes: 2 additions & 2 deletions config-parser/parsers/actions/lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package actions

import (
"fmt"
stderrors "errors"
"strings"

"github.com/haproxytech/client-native/v6/config-parser/common"
Expand All @@ -38,7 +38,7 @@ func (f *Lua) Parse(parts []string, parserType types.ParserType, comment string)
f.Comment = comment
}
if len(parts) < 2 {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
var data string
var command []string
Expand Down
3 changes: 2 additions & 1 deletion config-parser/parsers/actions/reject.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package actions

import (
stderrors "errors"
"fmt"
"strings"

Expand Down Expand Up @@ -50,7 +51,7 @@ func (f *Reject) Parse(parts []string, parserType types.ParserType, comment stri
return nil
}
if len(parts) < requiredLen {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
_, condition := common.SplitRequest(command)
if len(condition) > 1 {
Expand Down
4 changes: 2 additions & 2 deletions config-parser/parsers/actions/sc-inc-gpc0.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
package actions

import (
"fmt"
stderrors "errors"
"strings"

"github.com/haproxytech/client-native/v6/config-parser/common"
Expand Down Expand Up @@ -57,7 +57,7 @@ func (f *ScIncGpc0) Parse(parts []string, parserType types.ParserType, comment s
return nil
}
if len(parts) < requiredLen {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
_, condition := common.SplitRequest(command)
if len(condition) > 1 {
Expand Down
4 changes: 2 additions & 2 deletions config-parser/parsers/actions/sc-inc-gpc1.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
package actions

import (
"fmt"
stderrors "errors"
"strings"

"github.com/haproxytech/client-native/v6/config-parser/common"
Expand Down Expand Up @@ -57,7 +57,7 @@ func (f *ScIncGpc1) Parse(parts []string, parserType types.ParserType, comment s
return nil
}
if len(parts) < requiredLen {
return fmt.Errorf("not enough params")
return stderrors.New("not enough params")
}
_, condition := common.SplitRequest(command)
if len(condition) > 1 {
Expand Down
Loading

0 comments on commit ba9cae2

Please sign in to comment.