Skip to content

Commit a46af9a

Browse files
committed
Fix lint errors found on linter upgrade.
1 parent 35153e7 commit a46af9a

File tree

12 files changed

+30
-31
lines changed

12 files changed

+30
-31
lines changed

cmd/agent/app/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func NewAgentCommand(a *Agent, o *options.GrpcProxyAgentOptions) *cobra.Command
6161
cmd := &cobra.Command{
6262
Use: "agent",
6363
Long: `A gRPC agent, Connects to the proxy and then allows traffic to be forwarded to it.`,
64-
RunE: func(cmd *cobra.Command, args []string) error {
64+
RunE: func(_ *cobra.Command, _ []string) error {
6565
drainCh, stopCh := SetupSignalHandler()
6666
return a.Run(o, drainCh, stopCh)
6767
},
@@ -182,7 +182,7 @@ func (a *Agent) runProxyConnection(o *options.GrpcProxyAgentOptions, drainCh, st
182182
}
183183

184184
func (a *Agent) runHealthServer(o *options.GrpcProxyAgentOptions, cs agent.ReadinessManager) error {
185-
livenessHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
185+
livenessHandler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
186186
fmt.Fprintf(w, "ok")
187187
})
188188

cmd/server/app/server.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func NewProxyCommand(p *Proxy, o *options.ProxyRunOptions) *cobra.Command {
6464
cmd := &cobra.Command{
6565
Use: "proxy",
6666
Long: `A gRPC proxy server, receives requests from the API server and forwards to the agent.`,
67-
RunE: func(cmd *cobra.Command, args []string) error {
67+
RunE: func(_ *cobra.Command, _ []string) error {
6868
stopCh := SetupSignalHandler()
6969
return p.Run(o, stopCh)
7070
},
@@ -451,10 +451,10 @@ func (p *Proxy) runAdminServer(o *options.ProxyRunOptions, _ *server.ProxyServer
451451
}
452452

453453
func (p *Proxy) runHealthServer(o *options.ProxyRunOptions, server *server.ProxyServer) error {
454-
livenessHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
454+
livenessHandler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
455455
fmt.Fprintf(w, "ok")
456456
})
457-
readinessHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
457+
readinessHandler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
458458
ready, msg := server.Readiness.Ready()
459459
if ready {
460460
w.WriteHeader(200)

cmd/test-client/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func newGrpcProxyClientCommand(c *Client, o *GrpcProxyClientOptions) *cobra.Comm
216216
cmd := &cobra.Command{
217217
Use: "proxy-client",
218218
Long: `A gRPC proxy Client, primarily used to test the Kubernetes gRPC Proxy Server.`,
219-
RunE: func(cmd *cobra.Command, args []string) error {
219+
RunE: func(cmd *cobra.Command, _ []string) error {
220220
cmd.SilenceUsage = true
221221
return c.run(o)
222222
},
@@ -479,7 +479,7 @@ func (c *Client) getUDSDialer(o *GrpcProxyClientOptions) (func(ctx context.Conte
479479
return nil, fmt.Errorf("failed to process mode %s", o.mode)
480480
}
481481

482-
return func(ctx context.Context, network, addr string) (net.Conn, error) {
482+
return func(_ context.Context, _, _ string) (net.Conn, error) {
483483
return proxyConn, nil
484484
}, nil
485485
}
@@ -556,7 +556,7 @@ func (c *Client) getMTLSDialer(o *GrpcProxyClientOptions) (func(ctx context.Cont
556556
return nil, fmt.Errorf("failed to process mode %s", o.mode)
557557
}
558558

559-
return func(ctx context.Context, network, addr string) (net.Conn, error) {
559+
return func(_ context.Context, _, _ string) (net.Conn, error) {
560560
return proxyConn, nil
561561
}, nil
562562
}

cmd/test-server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func newTestServerCommand(p *TestServer, o *TestServerRunOptions) *cobra.Command
8989
cmd := &cobra.Command{
9090
Use: "test http server",
9191
Long: `A test http server, url determines behavior for certain tests.`,
92-
RunE: func(cmd *cobra.Command, args []string) error {
92+
RunE: func(_ *cobra.Command, _ []string) error {
9393
return p.run(o)
9494
},
9595
}

pkg/agent/client.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,14 @@ func (a *Client) remoteToProxy(connID int64, eConn *endpointConn) {
553553
klog.ErrorS(err, "connection read failure", "connectionID", connID)
554554
}
555555
return
556-
} else {
557-
resp.Payload = &client.Packet_Data{Data: &client.Data{
558-
Data: buf[:n],
559-
ConnectID: connID,
560-
}}
561-
if err := a.Send(resp); err != nil {
562-
klog.ErrorS(err, "could not send DATA", "connectionID", connID)
563-
}
556+
}
557+
558+
resp.Payload = &client.Packet_Data{Data: &client.Data{
559+
Data: buf[:n],
560+
ConnectID: connID,
561+
}}
562+
if err := a.Send(resp); err != nil {
563+
klog.ErrorS(err, "could not send DATA", "connectionID", connID)
564564
}
565565
}
566566
}

pkg/agent/client_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestServeData_HTTP(t *testing.T) {
5454

5555
// Start test http server as remote service
5656
expectedBody := "Hello, client"
57-
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
57+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
5858
fmt.Fprint(w, expectedBody)
5959
}))
6060
defer ts.Close()
@@ -152,7 +152,7 @@ func TestClose_Client(t *testing.T) {
152152
defer close(stopCh)
153153

154154
// Start test http server as remote service
155-
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
155+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
156156
fmt.Fprint(w, "hello, world")
157157
}))
158158
defer ts.Close()

pkg/server/backend_manager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ func NewDefaultBackendStorage(idTypes []header.IdentifierType) *DefaultBackendSt
287287
metrics.Metrics.SetBackendCount(0)
288288
return &DefaultBackendStorage{
289289
backends: make(map[string][]*Backend),
290-
random: rand.New(rand.NewSource(time.Now().UnixNano())),
290+
random: rand.New(rand.NewSource(time.Now().UnixNano())), /* #nosec G404 */
291291
idTypes: idTypes,
292-
} /* #nosec G404 */
292+
}
293293
}
294294

295295
func containIDType(idTypes []header.IdentifierType, idType header.IdentifierType) bool {

pkg/server/server.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ func (c *ProxyClientConnection) send(pkt *client.Packet) error {
132132
return c.CloseHTTP()
133133
}
134134
return nil
135-
} else {
136-
return fmt.Errorf("attempt to send via unrecognized connection type %v", pkt.Type)
137135
}
136+
return fmt.Errorf("attempt to send via unrecognized connection type %v", pkt.Type)
138137
}
139138
return fmt.Errorf("attempt to send via unrecognized connection mode %q", c.Mode)
140139
}

pkg/server/server_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestAgentTokenAuthenticationErrorsToken(t *testing.T) {
137137
t.Run(tc.desc, func(t *testing.T) {
138138
kcs := k8sfake.NewSimpleClientset()
139139

140-
kcs.AuthenticationV1().(*fakeauthenticationv1.FakeAuthenticationV1).Fake.PrependReactor("create", "tokenreviews", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
140+
kcs.AuthenticationV1().(*fakeauthenticationv1.FakeAuthenticationV1).Fake.PrependReactor("create", "tokenreviews", func(_ k8stesting.Action) (handled bool, ret runtime.Object, err error) {
141141
tr := &authv1.TokenReview{
142142
Status: authv1.TokenReviewStatus{
143143
Authenticated: tc.authenticated,
@@ -809,7 +809,7 @@ func TestServerProxyRecvChanFull(t *testing.T) {
809809
}
810810

811811
func TestServerProxyNoDial(t *testing.T) {
812-
baseServerProxyTestWithBackend(t, func(frontendConn, agentConn *agentmock.MockAgentService_ConnectServer) {
812+
baseServerProxyTestWithBackend(t, func(frontendConn, _ *agentmock.MockAgentService_ConnectServer) {
813813
const connectID = 123456
814814
data := &client.Packet{
815815
Type: client.PacketType_DATA,

tests/agent_disconnect_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func createHTTPConnectClient(_ context.Context, proxyAddr, addr string) (*http.C
216216
return nil, fmt.Errorf("unexpected extra buffer")
217217
}
218218

219-
dialer := func(network, addr string) (net.Conn, error) {
219+
dialer := func(_, _ string) (net.Conn, error) {
220220
return conn, nil
221221
}
222222

tests/custom_alpn_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestCustomALPN(t *testing.T) {
4040
svr := httptest.NewUnstartedServer(http.DefaultServeMux)
4141
svr.TLS = &tls.Config{NextProtos: []string{proto}, MinVersion: tls.VersionTLS13}
4242
svr.Config.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){
43-
proto: func(svr *http.Server, conn *tls.Conn, handle http.Handler) {
43+
proto: func(*http.Server, *tls.Conn, http.Handler) {
4444
atomic.AddInt32(&protoUsed, 1)
4545
},
4646
}

tests/proxy_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func TestProxyDial_RequestCancelled_Concurrent_GRPC(t *testing.T) {
362362
waitForConnectedServerCount(t, 1, a)
363363

364364
wg := sync.WaitGroup{}
365-
dialFn := func(id int, cancelDelay time.Duration) {
365+
dialFn := func(_ int, cancelDelay time.Duration) {
366366
defer wg.Done()
367367

368368
// run test client
@@ -615,7 +615,7 @@ func TestBasicProxy_HTTPCONN(t *testing.T) {
615615
t.Error("unexpected extra buffer")
616616
}
617617

618-
dialer := func(network, addr string) (net.Conn, error) {
618+
dialer := func(_, _ string) (net.Conn, error) {
619619
return conn, nil
620620
}
621621

@@ -679,7 +679,7 @@ func TestFailedDNSLookupProxy_HTTPCONN(t *testing.T) {
679679
if br.Buffered() > 0 {
680680
t.Error("unexpected extra buffer")
681681
}
682-
dialer := func(network, addr string) (net.Conn, error) {
682+
dialer := func(_, _ string) (net.Conn, error) {
683683
return conn, nil
684684
}
685685

@@ -753,7 +753,7 @@ func TestFailedDial_HTTPCONN(t *testing.T) {
753753
t.Fatalf("expect 200; got %d", res.StatusCode)
754754
}
755755

756-
dialer := func(network, addr string) (net.Conn, error) {
756+
dialer := func(_, _ string) (net.Conn, error) {
757757
return conn, nil
758758
}
759759

0 commit comments

Comments
 (0)