diff --git a/api/http_server.go b/api/http_server.go index 882a083b..f3c350fa 100644 --- a/api/http_server.go +++ b/api/http_server.go @@ -35,7 +35,7 @@ func StartHTTPAPI(options *Options) { mux := http.NewServeMux() mux.Handle("/", rmux) - mux.HandleFunc("/healthz", func(writer http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/healthz", func(writer http.ResponseWriter, _ *http.Request) { if liveness(options.Servers) { writer.Header().Set("Content-Type", "application/json") writer.WriteHeader(http.StatusOK) @@ -52,7 +52,7 @@ func StartHTTPAPI(options *Options) { } }) - mux.HandleFunc("/version", func(writer http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/version", func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusOK) if _, err := writer.Write([]byte(config.Version)); err != nil { options.Logger.Err(err).Msg("failed to serve version") @@ -61,7 +61,7 @@ func StartHTTPAPI(options *Options) { }) if IsSwaggerEmbedded() { - mux.HandleFunc("/swagger.json", func(writer http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/swagger.json", func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusOK) data, _ := swaggerUI.ReadFile("v1/api.swagger.json") if _, err := writer.Write(data); err != nil { diff --git a/cmd/config.go b/cmd/config.go index a68be5fa..0c752c06 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -10,7 +10,7 @@ import ( var configCmd = &cobra.Command{ Use: "config", Short: "Manage GatewayD global configuration", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { if err := cmd.Help(); err != nil { log.New(cmd.OutOrStdout(), "", 0).Fatal(err) } diff --git a/cmd/config_init.go b/cmd/config_init.go index fe9ba030..57c33dd9 100644 --- a/cmd/config_init.go +++ b/cmd/config_init.go @@ -12,7 +12,7 @@ var force bool var configInitCmd = &cobra.Command{ Use: "init", Short: "Create or overwrite the GatewayD global config", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { // Enable Sentry. if enableSentry { // Initialize Sentry. diff --git a/cmd/config_lint.go b/cmd/config_lint.go index a9c67c52..fa52e314 100644 --- a/cmd/config_lint.go +++ b/cmd/config_lint.go @@ -13,7 +13,7 @@ import ( var configLintCmd = &cobra.Command{ Use: "lint", Short: "Lint the GatewayD global config", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { // Enable Sentry. if enableSentry { // Initialize Sentry. diff --git a/cmd/plugin.go b/cmd/plugin.go index 82cc221b..ee0514f9 100644 --- a/cmd/plugin.go +++ b/cmd/plugin.go @@ -10,7 +10,7 @@ import ( var pluginCmd = &cobra.Command{ Use: "plugin", Short: "Manage plugins and their configuration", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { if err := cmd.Help(); err != nil { log.New(cmd.OutOrStdout(), "", 0).Fatal(err) } diff --git a/cmd/plugin_init.go b/cmd/plugin_init.go index 278a92cf..54b829c5 100644 --- a/cmd/plugin_init.go +++ b/cmd/plugin_init.go @@ -10,7 +10,7 @@ import ( var pluginInitCmd = &cobra.Command{ Use: "init", Short: "Create or overwrite the GatewayD plugins config", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { // Enable Sentry. if enableSentry { // Initialize Sentry. diff --git a/cmd/plugin_install_test.go b/cmd/plugin_install_test.go index ff5c1444..16edaeeb 100644 --- a/cmd/plugin_install_test.go +++ b/cmd/plugin_install_test.go @@ -40,7 +40,7 @@ func Test_pluginInstallCmd(t *testing.T) { // Clean up. assert.FileExists(t, "plugins/gatewayd-plugin-cache") - assert.FileExists(t, fmt.Sprintf("%s.bak", pluginTestConfigFile)) + assert.FileExists(t, pluginTestConfigFile+BackupFileExt) assert.NoFileExists(t, "gatewayd-plugin-cache-linux-amd64-v0.2.4.tar.gz") assert.NoFileExists(t, "checksums.txt") assert.NoFileExists(t, "plugins/LICENSE") @@ -50,7 +50,7 @@ func Test_pluginInstallCmd(t *testing.T) { require.NoError(t, os.RemoveAll("plugins/")) require.NoError(t, os.Remove(pluginTestConfigFile)) - require.NoError(t, os.Remove(fmt.Sprintf("%s.bak", pluginTestConfigFile))) + require.NoError(t, os.Remove(pluginTestConfigFile+BackupFileExt)) } func Test_pluginInstallCmdAutomatedNoOverwrite(t *testing.T) { @@ -78,12 +78,12 @@ func Test_pluginInstallCmdAutomatedNoOverwrite(t *testing.T) { // Clean up. assert.FileExists(t, "plugins/gatewayd-plugin-cache") - assert.FileExists(t, fmt.Sprintf("%s.bak", pluginTestConfigFile)) + assert.FileExists(t, pluginTestConfigFile+BackupFileExt) assert.NoFileExists(t, "plugins/LICENSE") assert.NoFileExists(t, "plugins/README.md") assert.NoFileExists(t, "plugins/checksum.txt") assert.NoFileExists(t, "plugins/gatewayd_plugin.yaml") require.NoError(t, os.RemoveAll("plugins/")) - require.NoError(t, os.Remove(fmt.Sprintf("%s.bak", pluginTestConfigFile))) + require.NoError(t, os.Remove(pluginTestConfigFile+BackupFileExt)) } diff --git a/cmd/plugin_lint.go b/cmd/plugin_lint.go index 9dbb5d4f..13508b3a 100644 --- a/cmd/plugin_lint.go +++ b/cmd/plugin_lint.go @@ -13,7 +13,7 @@ import ( var pluginLintCmd = &cobra.Command{ Use: "lint", Short: "Lint the GatewayD plugins config", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { // Enable Sentry. if enableSentry { // Initialize Sentry. diff --git a/cmd/plugin_list.go b/cmd/plugin_list.go index fa3a5f27..3bda53c2 100644 --- a/cmd/plugin_list.go +++ b/cmd/plugin_list.go @@ -12,7 +12,7 @@ var onlyEnabled bool var pluginListCmd = &cobra.Command{ Use: "list", Short: "List the GatewayD plugins", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { // Enable Sentry. if enableSentry { // Initialize Sentry. diff --git a/cmd/run.go b/cmd/run.go index a643a5db..6d0ba63b 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -148,7 +148,7 @@ func StopGracefully( var runCmd = &cobra.Command{ Use: "run", Short: "Run a GatewayD instance", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { // Enable tracing with OpenTelemetry. if enableTracing { // TODO: Make this configurable. @@ -427,7 +427,7 @@ var runCmd = &cobra.Command{ }() mux := http.NewServeMux() - mux.HandleFunc("/", func(responseWriter http.ResponseWriter, request *http.Request) { + mux.HandleFunc("/", func(responseWriter http.ResponseWriter, _ *http.Request) { // Serve a static page with a link to the metrics endpoint. if _, err := responseWriter.Write([]byte(fmt.Sprintf( `GatewayD Prometheus Metrics ServerMetrics`, @@ -878,7 +878,7 @@ var runCmd = &cobra.Command{ Plugins: []*usage.Plugin{}, } pluginRegistry.ForEach( - func(identifier sdkPlugin.Identifier, plugin *plugin.Plugin) { + func(identifier sdkPlugin.Identifier, _ *plugin.Plugin) { report.Plugins = append(report.GetPlugins(), &usage.Plugin{ Name: identifier.Name, Version: identifier.Version, diff --git a/cmd/run_test.go b/cmd/run_test.go index 438e2ec2..1ce11f1b 100644 --- a/cmd/run_test.go +++ b/cmd/run_test.go @@ -2,7 +2,6 @@ package cmd import ( "context" - "fmt" "os" "sync" "testing" @@ -269,5 +268,5 @@ func Test_runCmdWithCachePlugin(t *testing.T) { require.NoError(t, os.RemoveAll("plugins/")) require.NoError(t, os.Remove(globalTestConfigFile)) require.NoError(t, os.Remove(pluginTestConfigFile)) - require.NoError(t, os.Remove(fmt.Sprintf("%s.bak", pluginTestConfigFile))) + require.NoError(t, os.Remove(pluginTestConfigFile+BackupFileExt)) } diff --git a/cmd/utils.go b/cmd/utils.go index 550c62e2..425f6f71 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -42,6 +42,7 @@ const ( ExecFilePermissions os.FileMode = 0o755 ExecFileMask os.FileMode = 0o111 MaxFileSize int64 = 1024 * 1024 * 100 // 10MB + BackupFileExt string = ".bak" ) var ( @@ -737,7 +738,7 @@ func installPlugin(cmd *cobra.Command, pluginURL string) { // Check if the user wants to take a backup of the plugins configuration file. if backupConfig { - backupFilename := fmt.Sprintf("%s.bak", pluginConfigFile) + backupFilename := pluginConfigFile + BackupFileExt if err := os.WriteFile(backupFilename, pluginsConfig, FilePermissions); err != nil { cmd.Println("There was an error backing up the plugins configuration file: ", err) } diff --git a/config/config.go b/config/config.go index f3251a89..892e8ebe 100644 --- a/config/config.go +++ b/config/config.go @@ -2,6 +2,7 @@ package config import ( "context" + goerrors "errors" "fmt" "log" "os" @@ -462,7 +463,7 @@ func (c *Config) ValidateGlobalConfig(ctx context.Context) { for _, err := range errors { log.Println(err) } - span.RecordError(fmt.Errorf("failed to validate global configuration")) + span.RecordError(goerrors.New("failed to validate global configuration")) span.End() log.Fatal("failed to validate global configuration") } diff --git a/go.mod b/go.mod index d0f73c3a..91a2d6d5 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/codingsince1985/checksum v1.3.0 github.com/envoyproxy/protoc-gen-validate v1.0.4 github.com/gatewayd-io/gatewayd-plugin-sdk v0.1.10 - github.com/getsentry/sentry-go v0.26.0 + github.com/getsentry/sentry-go v0.27.0 github.com/go-co-op/gocron v1.37.0 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v53 v53.2.0 @@ -27,13 +27,13 @@ require ( github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.8.4 github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 - go.opentelemetry.io/otel v1.22.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 - go.opentelemetry.io/otel/sdk v1.22.0 - go.opentelemetry.io/otel/trace v1.22.0 - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a - google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe + go.opentelemetry.io/otel v1.23.1 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.23.1 + go.opentelemetry.io/otel/sdk v1.23.1 + go.opentelemetry.io/otel/trace v1.23.1 + golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 + google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.61.0 google.golang.org/protobuf v1.32.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 @@ -72,15 +72,15 @@ require ( github.com/robfig/cron/v3 v3.0.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect - go.opentelemetry.io/otel/metric v1.22.0 // indirect + go.opentelemetry.io/otel/metric v1.23.1 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/crypto v0.19.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect + golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect ) diff --git a/go.sum b/go.sum index 0709db5b..57bad041 100644 --- a/go.sum +++ b/go.sum @@ -83,8 +83,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/gatewayd-io/gatewayd-plugin-sdk v0.1.10 h1:jtHzHtekVEK13d6hqleFZ41D8SWABF4R2JHhOHFQOmc= github.com/gatewayd-io/gatewayd-plugin-sdk v0.1.10/go.mod h1:AS9WVWdp0av0D2sZkRM9ZOZMMp3DpNnwDsnmwNGCCrM= -github.com/getsentry/sentry-go v0.26.0 h1:IX3++sF6/4B5JcevhdZfdKIHfyvMmAq/UnqcyT2H6mA= -github.com/getsentry/sentry-go v0.26.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0= github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY= @@ -372,18 +372,18 @@ github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04/go.mod h1:FiwNQ go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY= -go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= -go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 h1:9M3+rhx7kZCIQQhQRYaZCdNu1V73tm4TvXs2ntl98C4= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0/go.mod h1:noq80iT8rrHP1SfybmPiRGc9dc5M8RPmGvtwo7Oo7tc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 h1:H2JFgRcGiyHg7H7bwcwaQJYrNFqCqrbTQ8K4p1OvDu8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0/go.mod h1:WfCWp1bGoYK8MeULtI15MmQVczfR+bFkk0DF3h06QmQ= -go.opentelemetry.io/otel/metric v1.22.0 h1:lypMQnGyJYeuYPhOM/bgjbFM6WE44W1/T45er4d8Hhg= -go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= -go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= -go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= -go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= -go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= +go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY= +go.opentelemetry.io/otel v1.23.1/go.mod h1:Td0134eafDLcTS4y+zQ26GE8u3dEuRBiBCTUIRHaikA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1 h1:o8iWeVFa1BcLtVEV0LzrCxV2/55tB3xLxADr6Kyoey4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1/go.mod h1:SEVfdK4IoBnbT2FXNM/k8yC08MrfbhWk3U4ljM8B3HE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.23.1 h1:p3A5+f5l9e/kuEBwLOrnpkIDHQFlHmbiVxMURWRK6gQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.23.1/go.mod h1:OClrnXUjBqQbInvjJFjYSnMxBSCXBF8r3b34WqjiIrQ= +go.opentelemetry.io/otel/metric v1.23.1 h1:PQJmqJ9u2QaJLBOELl1cxIdPcpbwzbkjfEyelTl2rlo= +go.opentelemetry.io/otel/metric v1.23.1/go.mod h1:mpG2QPlAfnK8yNhNJAxDZruU9Y1/HubbC+KyH8FaCWI= +go.opentelemetry.io/otel/sdk v1.23.1 h1:O7JmZw0h76if63LQdsBMKQDWNb5oEcOThG9IrxscV+E= +go.opentelemetry.io/otel/sdk v1.23.1/go.mod h1:LzdEVR5am1uKOOwfBWFef2DCi1nu3SA8XQxx2IerWFk= +go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6HmYY8= +go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI= go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -402,11 +402,11 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -438,13 +438,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -498,8 +498,8 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -546,12 +546,12 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe h1:USL2DhxfgRchafRvt/wYyyQNzwgL7ZiURcozOE/Pkvo= -google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:0poefMBYvYbs7g5UkjS6HcxBPaTRAmznle9jnxYoAI8= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 h1:g/4bk7P6TPMkAUbUhquq98xey1slwvuVJPosdBqYJlU= +google.golang.org/genproto v0.0.0-20240205150955-31a09d347014/go.mod h1:xEgQu1e4stdSSsxPDK8Azkrk/ECl5HvdPf6nbZrTS5M= +google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 h1:x9PwdEgd11LgK+orcck69WVRo7DezSO4VUMPI4xpc8A= +google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 h1:FSL3lRCkhaPFxqi0s9o+V4UI2WTzAVOvkgbd4kVV4Wg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014/go.mod h1:SaPjaZGWb0lPqs6Ittu0spdfrOArqji4ZdeP5IC/9N4= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= diff --git a/network/proxy.go b/network/proxy.go index b85c9c63..3af93ca7 100644 --- a/network/proxy.go +++ b/network/proxy.go @@ -313,7 +313,7 @@ func (pr *Proxy) PassThroughToServer(conn *ConnWrapper, stack *Stack) *gerr.Gate //nolint:nestif if conn.IsTLSEnabled() && IsPostgresSSLRequest(request) { // Perform TLS handshake. - if err := conn.UpgradeToTLS(func(c net.Conn) { + if err := conn.UpgradeToTLS(func(net.Conn) { // Acknowledge the SSL request: // https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-SSL if sent, err := conn.Write([]byte{'S'}); err != nil { @@ -601,7 +601,7 @@ func (pr *Proxy) Shutdown() { _, span := otel.Tracer(config.TracerName).Start(pr.ctx, "Shutdown") defer span.End() - pr.availableConnections.ForEach(func(key, value interface{}) bool { + pr.availableConnections.ForEach(func(_, value interface{}) bool { if client, ok := value.(*Client); ok { if client.IsConnected() { client.Close() diff --git a/plugin/plugin_registry_test.go b/plugin/plugin_registry_test.go index 67beb0bf..026aa2a4 100644 --- a/plugin/plugin_registry_test.go +++ b/plugin/plugin_registry_test.go @@ -68,9 +68,9 @@ func TestPluginRegistry(t *testing.T) { // Test_HookRegistry_Add tests the Add function. func Test_PluginRegistry_AddHook(t *testing.T) { testFunc := func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil } @@ -85,16 +85,16 @@ func Test_PluginRegistry_AddHook(t *testing.T) { func Test_PluginRegistry_AddHook_Multiple(t *testing.T) { reg := NewPluginRegistry(t) reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 0, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil }) reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 1, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil }) @@ -107,9 +107,9 @@ func Test_PluginRegistry_Run(t *testing.T) { reg := NewPluginRegistry(t) reg.Verification = config.Ignore reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 0, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil }) @@ -124,17 +124,17 @@ func Test_PluginRegistry_Run_PassDown(t *testing.T) { reg.Verification = config.PassDown // The result of the hook will be nil and will be passed down to the next reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 0, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil }) // The consolidated result should be {"test": "test"}. reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 1, func( - ctx context.Context, - args *v1.Struct, - opts ...grpc.CallOption, + context.Context, + *v1.Struct, + ...grpc.CallOption, ) (*v1.Struct, error) { output, err := v1.NewStruct(map[string]interface{}{ "test": "test", @@ -160,9 +160,9 @@ func Test_HookRegistry_Run_PassDown_2(t *testing.T) { reg.Verification = config.PassDown // The result of the hook will be nil and will be passed down to the next reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 0, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { args.Fields["test1"] = &v1.Value{ Kind: &v1.Value_StringValue{ @@ -173,9 +173,9 @@ func Test_HookRegistry_Run_PassDown_2(t *testing.T) { }) // The consolidated result should be {"test1": "test1", "test2": "test2"}. reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 1, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { args.Fields["test2"] = &v1.Value{ Kind: &v1.Value_StringValue{ @@ -201,17 +201,17 @@ func Test_HookRegistry_Run_Ignore(t *testing.T) { reg.Verification = config.Ignore // This should not run, because the return value is not the same as the params reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 0, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil }) // This should run, because the return value is the same as the params reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 1, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { args.Fields["test"] = &v1.Value{ Kind: &v1.Value_StringValue{ @@ -237,17 +237,17 @@ func Test_HookRegistry_Run_Abort(t *testing.T) { reg.Verification = config.Abort // This should not run, because the return value is not the same as the params reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 0, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil }) // This should not run, because the first hook returns nil, and its result is ignored. reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 1, func( - ctx context.Context, - args *v1.Struct, - opts ...grpc.CallOption, + context.Context, + *v1.Struct, + ...grpc.CallOption, ) (*v1.Struct, error) { output, err := v1.NewStruct(map[string]interface{}{ "test": "test", @@ -267,17 +267,17 @@ func Test_HookRegistry_Run_Remove(t *testing.T) { reg.Verification = config.Remove // This should not run, because the return value is not the same as the params reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 0, func( - ctx context.Context, + _ context.Context, args *v1.Struct, - opts ...grpc.CallOption, + _ ...grpc.CallOption, ) (*v1.Struct, error) { return args, nil }) // This should not run, because the first hook returns nil, and its result is ignored. reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, 1, func( - ctx context.Context, - args *v1.Struct, - opts ...grpc.CallOption, + context.Context, + *v1.Struct, + ...grpc.CallOption, ) (*v1.Struct, error) { output, err := v1.NewStruct(map[string]interface{}{ "test": "test", @@ -314,7 +314,7 @@ func BenchmarkHookRun(b *testing.B) { ) reg.Verification = config.PassDown hookFunction := func( - ctx context.Context, args *v1.Struct, opts ...grpc.CallOption, + _ context.Context, args *v1.Struct, _ ...grpc.CallOption, ) (*v1.Struct, error) { args.Fields["test"] = v1.NewStringValue("test1") return args, nil diff --git a/pool/pool_test.go b/pool/pool_test.go index f43df0ac..03529e91 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -91,7 +91,7 @@ func TestPool_ForEach(t *testing.T) { err = pool.Put("client2.ID", "client2") assert.Nil(t, err) assert.Equal(t, 2, pool.Size()) - pool.ForEach(func(key, value interface{}) bool { + pool.ForEach(func(_, value interface{}) bool { if c, ok := value.(string); ok { assert.NotEmpty(t, c) } @@ -195,7 +195,7 @@ func TestPool_GetClientIDs(t *testing.T) { assert.Equal(t, 2, pool.Size()) var ids []string - pool.ForEach(func(key, value interface{}) bool { + pool.ForEach(func(key, _ interface{}) bool { if id, ok := key.(string); ok { ids = append(ids, id) } @@ -253,7 +253,7 @@ func BenchmarkPool_ForEach(b *testing.B) { pool.Put("client1.ID", "client1") //nolint:errcheck pool.Put("client2.ID", "client2") //nolint:errcheck for i := 0; i < b.N; i++ { - pool.ForEach(func(key, value interface{}) bool { + pool.ForEach(func(_, _ interface{}) bool { return true }) }