Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update linter version #104

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.1
version: v1.59.1
1 change: 1 addition & 0 deletions agent/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func handler(w http.ResponseWriter, _ *http.Request) {
// nolint
fmt.Fprintln(w, "Hello from Piko")
}

Expand Down
2 changes: 1 addition & 1 deletion agent/reverseproxy/reverseproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestReverseProxy_Forward(t *testing.T) {
t.Run("timeout", func(t *testing.T) {
blockCh := make(chan struct{})
upstream := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
func(_ http.ResponseWriter, _ *http.Request) {
<-blockCh
},
))
Expand Down
2 changes: 1 addition & 1 deletion cli/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Examples:
conf.RegisterFlags(cmd.PersistentFlags())
loadConf.RegisterFlags(cmd.PersistentFlags())

cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
cmd.PersistentPreRun = func(_ *cobra.Command, _ []string) {
if err := loadConf.Load(&conf); err != nil {
fmt.Println(err.Error())
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Timeout forwarding incoming HTTP requests to the upstream.`,

var logger log.Logger

cmd.PreRun = func(cmd *cobra.Command, args []string) {
cmd.PreRun = func(_ *cobra.Command, args []string) {
// Discard any listeners in the configuration file and use from command
// line.
conf.Listeners = []config.ListenerConfig{{
Expand All @@ -73,7 +73,7 @@ Timeout forwarding incoming HTTP requests to the upstream.`,
}
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := runAgent(conf, logger); err != nil {
logger.Error("failed to run agent", zap.Error(err))
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/agent/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Examples:

var logger log.Logger

cmd.PreRun = func(cmd *cobra.Command, args []string) {
cmd.PreRun = func(_ *cobra.Command, _ []string) {
var err error
logger, err = log.NewLogger(conf.Log.Level, conf.Log.Subsystems)
if err != nil {
Expand All @@ -39,7 +39,7 @@ Examples:
}
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := runAgent(conf, logger); err != nil {
logger.Error("failed to run agent", zap.Error(err))
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/agent/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Timeout connecting to the upstream.`,

var logger log.Logger

cmd.PreRun = func(cmd *cobra.Command, args []string) {
cmd.PreRun = func(_ *cobra.Command, args []string) {
// Discard any listeners in the configuration file and use from command
// line.
conf.Listeners = []config.ListenerConfig{{
Expand All @@ -70,7 +70,7 @@ Timeout connecting to the upstream.`,
}
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := runAgent(conf, logger); err != nil {
logger.Error("failed to run agent", zap.Error(err))
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cli/forward/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Examples:
conf.RegisterFlags(cmd.PersistentFlags())
loadConf.RegisterFlags(cmd.PersistentFlags())

cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
cmd.PersistentPreRun = func(_ *cobra.Command, _ []string) {
if err := loadConf.Load(&conf); err != nil {
fmt.Println(err.Error())
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/forward/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Examples:

var logger log.Logger

cmd.PreRun = func(cmd *cobra.Command, args []string) {
cmd.PreRun = func(_ *cobra.Command, _ []string) {
var err error
logger, err = log.NewLogger(conf.Log.Level, conf.Log.Subsystems)
if err != nil {
Expand All @@ -39,7 +39,7 @@ Examples:
}
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := runForward(conf, logger); err != nil {
logger.Error("failed to run forward", zap.Error(err))
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/forward/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Examples:

var logger log.Logger

cmd.PreRun = func(cmd *cobra.Command, args []string) {
cmd.PreRun = func(_ *cobra.Command, args []string) {
// Discard any ports in the configuration file and use from command
// line.
conf.Ports = []config.PortConfig{{
Expand All @@ -46,7 +46,7 @@ Examples:
}
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := runForward(conf, logger); err != nil {
logger.Error("failed to run forward", zap.Error(err))
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Examples:

var logger log.Logger

cmd.PreRun = func(cmd *cobra.Command, args []string) {
cmd.PreRun = func(_ *cobra.Command, _ []string) {
if err := loadConf.Load(&conf); err != nil {
fmt.Println(err.Error())
os.Exit(1)
Expand Down Expand Up @@ -134,7 +134,7 @@ Examples:
}
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := runServer(&conf, logger); err != nil {
logger.Error("failed to run agent", zap.Error(err))
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/server/status/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Examples:
`,
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
showClusterNodes(c)
}

Expand Down Expand Up @@ -88,7 +88,7 @@ Examples:
`,
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, args []string) {
showClusterNode(args[0], c)
}

Expand Down
2 changes: 1 addition & 1 deletion cli/server/status/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Examples:

c := client.NewClient(nil)

cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
cmd.PersistentPreRun = func(_ *cobra.Command, _ []string) {
if err := conf.Validate(); err != nil {
fmt.Printf("config: %s\n", err.Error())
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions cli/server/status/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Examples:
`,
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
showGossipNodes(c)
}

Expand Down Expand Up @@ -83,7 +83,7 @@ Examples:
`,
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, args []string) {
showGossipNode(args[0], c)
}

Expand Down
2 changes: 1 addition & 1 deletion cli/server/status/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Examples:
`,
}

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
showUpstreamEndpoints(c)
}

Expand Down
2 changes: 1 addition & 1 deletion cli/workload/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Examples:
// Register flags and set default values.
conf.RegisterFlags(cmd.Flags())

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := conf.Validate(); err != nil {
fmt.Printf("invalid config: %s\n", err.Error())
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cli/workload/upstreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Examples:
// Register flags and set default values.
conf.RegisterFlags(cmd.Flags())

cmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Run = func(_ *cobra.Command, _ []string) {
if err := conf.Validate(); err != nil {
fmt.Printf("invalid config: %s\n", err.Error())
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion pkg/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (l *nopLogger) Sync() error {

func (l *nopLogger) StdLogger(_ zapcore.Level) *stdlog.Logger {
return stdlog.New(&loggerWriter{
logFunc: func(msg string, fields ...zap.Field) {
logFunc: func(_ string, _ ...zap.Field) {
},
}, "", 0)
}
Expand Down
9 changes: 8 additions & 1 deletion server/proxy/httpproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func TestHTTPProxy_Forward(t *testing.T) {
proxy := NewHTTPProxy(
&fakeManager{
handler: func(endpointID string, allowForward bool) (upstream.Upstream, bool) {
assert.Equal(t, "my-endpoint", endpointID)
assert.True(t, allowForward)
return &tcpUpstream{
addr: server.Listener.Addr().String(),
}, true
Expand Down Expand Up @@ -101,7 +103,7 @@ func TestHTTPProxy_Forward(t *testing.T) {
t.Run("timeout", func(t *testing.T) {
blockCh := make(chan struct{})
server := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
func(_ http.ResponseWriter, _ *http.Request) {
<-blockCh
},
))
Expand All @@ -111,6 +113,8 @@ func TestHTTPProxy_Forward(t *testing.T) {
proxy := NewHTTPProxy(
&fakeManager{
handler: func(endpointID string, allowForward bool) (upstream.Upstream, bool) {
assert.Equal(t, "my-endpoint", endpointID)
assert.True(t, allowForward)
return &tcpUpstream{
addr: server.Listener.Addr().String(),
}, true
Expand All @@ -121,6 +125,7 @@ func TestHTTPProxy_Forward(t *testing.T) {
)

r := httptest.NewRequest(http.MethodGet, "/", nil)
r.Header.Add("x-piko-endpoint", "my-endpoint")

w := httptest.NewRecorder()
proxy.ServeHTTP(w, r)
Expand All @@ -139,6 +144,8 @@ func TestHTTPProxy_Forward(t *testing.T) {
proxy := NewHTTPProxy(
&fakeManager{
handler: func(endpointID string, allowForward bool) (upstream.Upstream, bool) {
assert.Equal(t, "my-endpoint", endpointID)
assert.True(t, allowForward)
return &tcpUpstream{
addr: "localhost:55555",
}, true
Expand Down
4 changes: 4 additions & 0 deletions server/proxy/tcpproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func TestTCPProxy_Forward(t *testing.T) {
server := NewServer(
&fakeManager{
handler: func(endpointID string, allowForward bool) (upstream.Upstream, bool) {
assert.Equal(t, "my-endpoint", endpointID)
assert.True(t, allowForward)
return &tcpUpstream{
addr: echoLn.Addr().String(),
}, true
Expand Down Expand Up @@ -91,6 +93,8 @@ func TestTCPProxy_Forward(t *testing.T) {
proxy := NewTCPProxy(
&fakeManager{
handler: func(endpointID string, allowForward bool) (upstream.Upstream, bool) {
assert.Equal(t, "my-endpoint", endpointID)
assert.True(t, allowForward)
return &tcpUpstream{
addr: "localhost:55555",
}, true
Expand Down
6 changes: 3 additions & 3 deletions tests/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestCluster_Proxy(t *testing.T) {

remoteEndpointCh := make(chan string)
cluster.Nodes()[1].ClusterState().OnRemoteEndpointUpdate(
func(nodeID string, endpointID string) {
func(_ string, endpointID string) {
remoteEndpointCh <- endpointID
},
)
Expand All @@ -39,7 +39,7 @@ func TestCluster_Proxy(t *testing.T) {
assert.NoError(t, err)

server := httptest.NewUnstartedServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {},
func(_ http.ResponseWriter, _ *http.Request) {},
))
server.Listener = ln
go server.Start()
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestCluster_Proxy(t *testing.T) {

remoteEndpointCh := make(chan string)
cluster.Nodes()[1].ClusterState().OnRemoteEndpointUpdate(
func(nodeID string, endpointID string) {
func(_ string, endpointID string) {
remoteEndpointCh <- endpointID
},
)
Expand Down
Loading