diff --git a/.golangci.yml b/.golangci.yml index 0d8ddf4306..d830af46b8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,11 +14,11 @@ linters: enable: - bodyclose - cyclop + - copyloopvar - contextcheck - dupl - errorlint - exhaustive - - exportloopref - forcetypeassert - gocheckcompilerdirectives - gocognit @@ -28,7 +28,6 @@ linters: - godox - gofumpt - goheader - - gomnd - gomoddirectives - gosec - grouper @@ -40,6 +39,7 @@ linters: - makezero - mirror - misspell + - mnd - musttag - nakedret - nestif @@ -201,27 +201,6 @@ linters-settings: This source code is licensed under the Apache License, Version 2.0 license found in the LICENSE file in the root directory of this source tree. - gomnd: - # List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. - # Default: ["argument", "case", "condition", "operation", "return", "assign"] - checks: - - argument - - case - - condition - - operation - - return - - assign - # List of numbers to exclude from analysis. The numbers should be written as string. - # Values always ignored: "1", "1.0", "0" and "0.0". Default: [] - ignored-numbers: [] - # List of file patterns to exclude from analysis. Values always ignored: `.+_test.go`. Default: [] - ignored-files: [] - # List of function patterns to exclude from analysis. - # Following functions are always ignored: `time.Date`, - # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, - # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. - # Default: [] - ignored-functions: [] gomoddirectives: # Allow local `replace` directives. Default: false replace-local: false diff --git a/Makefile.tools b/Makefile.tools index 005e5f1267..23417c9a62 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -1,6 +1,6 @@ OAPICODEGEN = github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.1.0 LEFTHOOK = github.com/evilmartians/lefthook@v1.6.9 -GOLANGCILINT = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2 +GOLANGCILINT = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 PROTOCGENGO = google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0 GOFUMPT = mvdan.cc/gofumpt@v0.6.0 COUNTERFEITER = github.com/maxbrunsfeld/counterfeiter/v6@v6.8.1 diff --git a/go.mod b/go.mod index 8aad1c4a71..2db34881d4 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/nginx/agent/v3 -go 1.22.0 +go 1.23 -toolchain go1.22.5 +toolchain go1.23.2 require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240401165935-b983156c5e99.1 @@ -79,7 +79,7 @@ require ( go.opentelemetry.io/otel v1.28.0 go.uber.org/goleak v1.3.0 go.uber.org/zap v1.27.0 - golang.org/x/mod v0.19.0 + golang.org/x/mod v0.21.0 golang.org/x/sync v0.8.0 google.golang.org/protobuf v1.34.2 ) @@ -113,7 +113,7 @@ require ( github.com/elastic/go-grok v0.3.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/expr-lang/expr v1.16.9 // indirect - github.com/fatih/color v1.16.0 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect @@ -224,7 +224,7 @@ require ( github.com/openshift/api v3.9.0+incompatible // indirect github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142 // indirect github.com/openzipkin/zipkin-go v0.4.3 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect @@ -297,11 +297,11 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.7.0 // indirect - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect + golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/term v0.23.0 // indirect golang.org/x/time v0.6.0 // indirect - golang.org/x/tools v0.23.0 // indirect + golang.org/x/tools v0.24.0 // indirect gonum.org/v1/gonum v0.15.1 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect @@ -335,7 +335,7 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.28.0 golang.org/x/crypto v0.26.0 // indirect golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect google.golang.org/grpc v1.65.0 ) diff --git a/go.sum b/go.sum index 98201b527f..0ca9b3c655 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ github.com/expr-lang/expr v1.16.9/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= -github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= @@ -715,8 +715,8 @@ github.com/ovh/go-ovh v1.6.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= @@ -822,7 +822,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= @@ -1041,8 +1040,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1066,8 +1065,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1179,8 +1178,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1203,8 +1202,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1251,8 +1250,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= -golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/bus/message_pipe_test.go b/internal/bus/message_pipe_test.go index 5ac3dcc852..4bd91f5f3c 100644 --- a/internal/bus/message_pipe_test.go +++ b/internal/bus/message_pipe_test.go @@ -93,7 +93,7 @@ func TestMessagePipe_DeRegister(t *testing.T) { err = messagePipe.DeRegister(ctx, []string{plugin.Info().Name}) require.NoError(t, err) - assert.Empty(t, len(messagePipe.GetPlugins())) + assert.Empty(t, messagePipe.GetPlugins()) plugin.AssertExpectations(t) } diff --git a/internal/collector/nginxossreceiver/internal/scraper/accesslog/operator/input/file/grok_test.go b/internal/collector/nginxossreceiver/internal/scraper/accesslog/operator/input/file/grok_test.go index 337f00113f..72cbd0e012 100644 --- a/internal/collector/nginxossreceiver/internal/scraper/accesslog/operator/input/file/grok_test.go +++ b/internal/collector/nginxossreceiver/internal/scraper/accesslog/operator/input/file/grok_test.go @@ -5,7 +5,6 @@ package file import ( - "fmt" "testing" "github.com/stretchr/testify/assert" @@ -57,7 +56,6 @@ func TestGrok_Constructor(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - fmt.Printf(test.logFormat) grok, err := NewCompiledGrok(test.logFormat, test.logger) if test.shouldErr { require.Error(tt, err) diff --git a/internal/collector/nginxossreceiver/internal/scraper/stubstatus/stub_status_scraper_test.go b/internal/collector/nginxossreceiver/internal/scraper/stubstatus/stub_status_scraper_test.go index 7a8c7f0b4f..8ef8dfd74f 100644 --- a/internal/collector/nginxossreceiver/internal/scraper/stubstatus/stub_status_scraper_test.go +++ b/internal/collector/nginxossreceiver/internal/scraper/stubstatus/stub_status_scraper_test.go @@ -116,7 +116,8 @@ server accepts handled requests 16630948 16630946 31070465 Reading: 6 Writing: 179 Waiting: 106 `)) - require.NoError(t, err) + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) return } diff --git a/internal/grpc/grpc.go b/internal/grpc/grpc.go index e99572a235..4a558cad66 100644 --- a/internal/grpc/grpc.go +++ b/internal/grpc/grpc.go @@ -324,7 +324,7 @@ func validateMessage(validator *protovalidate.Validator, message any) error { validationErr := validator.Validate(protoMessage) if validationErr != nil { - return status.Errorf(codes.InvalidArgument, validationErr.Error()) + return status.Error(codes.InvalidArgument, validationErr.Error()) } return nil diff --git a/internal/grpc/grpc_test.go b/internal/grpc/grpc_test.go index 3a811294d6..4feaa0e3d8 100644 --- a/internal/grpc/grpc_test.go +++ b/internal/grpc/grpc_test.go @@ -28,6 +28,7 @@ import ( type ClientStream struct{} func (*ClientStream) Header() (metadata.MD, error) { + // nolint: nilnil return nil, nil } diff --git a/internal/resource/nginx_instance_operator_test.go b/internal/resource/nginx_instance_operator_test.go index 5fb7210e31..914eda6a84 100644 --- a/internal/resource/nginx_instance_operator_test.go +++ b/internal/resource/nginx_instance_operator_test.go @@ -157,7 +157,7 @@ func TestInstanceOperator_ReloadAndMonitor(t *testing.T) { name: "Test 2: Failed reload - error in logs", errorLogs: errorLogFile.Name(), errorLogContent: errorLogLine, - expectedErr: errors.Join(fmt.Errorf(errorLogLine)), + expectedErr: errors.Join(fmt.Errorf("%s", errorLogLine)), }, { name: "Test 3: Successful reload - no error log", diff --git a/internal/resource/nginx_log_tailer_operator.go b/internal/resource/nginx_log_tailer_operator.go index 6c3037ef5f..aadbffd4d9 100644 --- a/internal/resource/nginx_log_tailer_operator.go +++ b/internal/resource/nginx_log_tailer_operator.go @@ -60,7 +60,7 @@ func (l *NginxLogTailerOperator) Tail(ctx context.Context, errorLog string, erro select { case d := <-data: if l.doesLogLineContainError(d) { - errorChannel <- fmt.Errorf(d) + errorChannel <- fmt.Errorf("%s", d) return } case <-ctxWithTimeout.Done(): diff --git a/internal/resource/nginx_log_tailer_operator_test.go b/internal/resource/nginx_log_tailer_operator_test.go index 859f9d8e2a..5a364a5875 100644 --- a/internal/resource/nginx_log_tailer_operator_test.go +++ b/internal/resource/nginx_log_tailer_operator_test.go @@ -54,7 +54,7 @@ func TestLogOperator_Tail(t *testing.T) { errorLogs: errorLogFile.Name(), errorLogContents: errorLogLine, err: nil, - expected: errors.Join(fmt.Errorf(errorLogLine)), + expected: errors.Join(fmt.Errorf("%s", errorLogLine)), }, { name: "Test 3: Warning in error logs", @@ -62,7 +62,7 @@ func TestLogOperator_Tail(t *testing.T) { errorLogs: errorLogFile.Name(), errorLogContents: warningLogLine, err: nil, - expected: errors.Join(fmt.Errorf(warningLogLine)), + expected: errors.Join(fmt.Errorf("%s", warningLogLine)), }, } diff --git a/internal/watcher/instance/nginx_config_parser_test.go b/internal/watcher/instance/nginx_config_parser_test.go index 8be2c568b9..6f8c22dc18 100644 --- a/internal/watcher/instance/nginx_config_parser_test.go +++ b/internal/watcher/instance/nginx_config_parser_test.go @@ -540,16 +540,19 @@ func TestNginxConfigParser_pingPlusAPIEndpoint(t *testing.T) { if req.URL.String() == "/good_api" { data := []byte("[1,2,3,4,5,6,7,8]") _, err := rw.Write(data) - require.NoError(t, err) + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) } else if req.URL.String() == "/invalid_body_api" { data := []byte("Invalid") _, err := rw.Write(data) - require.NoError(t, err) + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) } else { rw.WriteHeader(http.StatusInternalServerError) data := []byte("") _, err := rw.Write(data) - require.NoError(t, err) + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) } }) @@ -601,16 +604,22 @@ server accepts handled requests Reading: 0 Writing: 1 Waiting: 1 `) _, err := rw.Write(data) - require.NoError(t, err) + + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) } else if req.URL.String() == "/invalid_body_api" { data := []byte("Invalid") _, err := rw.Write(data) - require.NoError(t, err) + + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) } else { rw.WriteHeader(http.StatusInternalServerError) data := []byte("") _, err := rw.Write(data) - require.NoError(t, err) + + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) } }) diff --git a/internal/watcher/instance/nginx_process_parser.go b/internal/watcher/instance/nginx_process_parser.go index f4dd768c99..e88fac4e5b 100644 --- a/internal/watcher/instance/nginx_process_parser.go +++ b/internal/watcher/instance/nginx_process_parser.go @@ -26,6 +26,8 @@ import ( const ( withWithPrefix = "with-" withModuleSuffix = "module" + keyValueLen = 2 + flagLen = 1 ) type ( @@ -315,12 +317,11 @@ func getNginxConfPath(ctx context.Context, nginxInfo *Info) string { } func isFlag(vals []string) bool { - return len(vals) == 1 && vals[0] != "" + return len(vals) == flagLen && vals[0] != "" } -// nolint: gomnd func isKeyValueFlag(vals []string) bool { - return len(vals) == 2 + return len(vals) == keyValueLen } func getLoadableModules(nginxInfo *Info) (modules []string) { diff --git a/scripts/packages/packager/Dockerfile b/scripts/packages/packager/Dockerfile index 703e8d892f..51be5e23a9 100644 --- a/scripts/packages/packager/Dockerfile +++ b/scripts/packages/packager/Dockerfile @@ -1,6 +1,6 @@ ARG package_type -FROM docker.io/golang:1.22-bullseye AS base +FROM docker.io/golang:1.23-bullseye AS base ARG PKG_VER="1.17.5" ARG PKG_DIR="/tmp/pkg" diff --git a/site/content/installation-upgrade/getting-started.md b/site/content/installation-upgrade/getting-started.md index 17c30ba1e0..e3be8c8095 100644 --- a/site/content/installation-upgrade/getting-started.md +++ b/site/content/installation-upgrade/getting-started.md @@ -22,7 +22,7 @@ Using your preferred method, clone the NGINX Agent repository into your developm ## Install Go -NGINX Agent and the Mock Control Plane are written in Go. Go 1.22.2 or higher is required to build and run either application from the source code directory. You can [download Go from the official website](https://go.dev/dl/). +NGINX Agent and the Mock Control Plane are written in Go. Go 1.23.0 or higher is required to build and run either application from the source code directory. You can [download Go from the official website](https://go.dev/dl/). ## Start the gRPC Mock Control Plane diff --git a/site/content/previous-versions/NGINX-agent-v2/installation-upgrade/getting-started.md b/site/content/previous-versions/NGINX-agent-v2/installation-upgrade/getting-started.md index c96aaa3d56..e7f3e96d69 100644 --- a/site/content/previous-versions/NGINX-agent-v2/installation-upgrade/getting-started.md +++ b/site/content/previous-versions/NGINX-agent-v2/installation-upgrade/getting-started.md @@ -23,7 +23,7 @@ Using your preferred method, clone the NGINX Agent repository into your developm ## Install Go -NGINX Agent and the Mock Control Plane are written in Go. Go 1.22.2 or higher is required to build and run either application from the source code directory. You can [download Go from the official website](https://go.dev/dl/). +NGINX Agent and the Mock Control Plane are written in Go. Go 1.23.0 or higher is required to build and run either application from the source code directory. You can [download Go from the official website](https://go.dev/dl/). ## Start the gRPC Mock Control Plane diff --git a/test/helpers/go_utils_test.go b/test/helpers/go_utils_test.go index 4d126b9c19..2caab7090a 100644 --- a/test/helpers/go_utils_test.go +++ b/test/helpers/go_utils_test.go @@ -13,7 +13,7 @@ import ( ) func TestGoVersion(t *testing.T) { - expected := "1.22.2" + expected := "1.23.0" actual, err := GoVersion(t, 2) diff --git a/test/helpers/nginx_plus.go b/test/helpers/nginx_plus.go index 3cd7b9e48a..e095bc4fae 100644 --- a/test/helpers/nginx_plus.go +++ b/test/helpers/nginx_plus.go @@ -11,7 +11,7 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) const endpointRootPath = "/api/9/" @@ -474,7 +474,9 @@ func NewMockNGINXPlusAPIServer(t *testing.T) *httptest.Server { if payload != "" { rw.WriteHeader(http.StatusOK) _, err := rw.Write([]byte(payload)) - require.NoError(t, err) + + // go-require: do not use require in http handlers (testifylint), using assert instead + assert.NoError(t, err) return } diff --git a/test/helpers/os_utils.go b/test/helpers/os_utils.go index 2804463d24..1a0a7ae1a7 100644 --- a/test/helpers/os_utils.go +++ b/test/helpers/os_utils.go @@ -51,13 +51,13 @@ func CreateCacheFiles(t testing.TB, cachePath string, cacheData map[string]*v1.F cache, err := json.MarshalIndent(cacheData, "", " ") require.NoError(t, err) - err = os.MkdirAll(path.Dir(cachePath), os.ModePerm) + err = os.MkdirAll(path.Dir(cachePath), filePermission) require.NoError(t, err) for _, file := range cacheData { CreateFileWithErrorCheck(t, filepath.Dir(file.GetName()), filepath.Base(file.GetName())) } - err = os.WriteFile(cachePath, cache, os.ModePerm) + err = os.WriteFile(cachePath, cache, filePermission) require.NoError(t, err) } diff --git a/test/integration/install_uninstall_test.go b/test/integration/install_uninstall_test.go index 3dc96d40e4..62eeb50320 100644 --- a/test/integration/install_uninstall_test.go +++ b/test/integration/install_uninstall_test.go @@ -178,8 +178,8 @@ func installAgent(ctx context.Context, tb testing.TB, container testcontainers.C require.NoError(tb, err) stdoutStderr, err := io.ReadAll(cmdOut) require.NoError(tb, err) - assert.Equal(tb, 0, exitCode, fmt.Sprintf("expected error code of 0 from cmd %q. Got:"+ - " %v\n %s", installCmd, exitCode, stdoutStderr)) + msg := fmt.Sprintf("expected error code of 0 from cmd %q. Got: %v\n %s", installCmd, exitCode, stdoutStderr) + assert.Equal(tb, 0, exitCode, msg) return string(stdoutStderr), time.Since(start) } @@ -192,8 +192,9 @@ func uninstallAgent(ctx context.Context, tb testing.TB, container testcontainers exitCode, cmdOut, err := container.Exec(ctx, uninstallCmd) require.NoError(tb, err) - assert.Equal(tb, 0, exitCode, fmt.Sprintf("expected error code of 0 from cmd %q. Got:"+ - " %v", uninstallCmd, exitCode)) + + msg := fmt.Sprintf("expected error code of 0 from cmd %q. Got: %v", uninstallCmd, exitCode) + assert.Equal(tb, 0, exitCode, msg) stdoutStderr, err := io.ReadAll(cmdOut) require.NoError(tb, err) @@ -207,7 +208,9 @@ func updateDebRepo(tb testing.TB, testContainer testcontainers.Container) { exitCode, _, err := testContainer.Exec(context.Background(), updateCmd) require.NoError(tb, err) - assert.Equal(tb, 0, exitCode, fmt.Sprintf("expected error code of 0 from cmd %q", exitCode)) + + msg := fmt.Sprintf("expected error code of 0 from cmd %q", exitCode) + assert.Equal(tb, 0, exitCode, msg) } func nginxIsRunning(ctx context.Context, container testcontainers.Container) bool {