From 963e3f54579fcccd769464af18a05aa7a4d52803 Mon Sep 17 00:00:00 2001 From: pascal Date: Thu, 12 Feb 2026 01:15:36 +0100 Subject: [PATCH] fix linter issues --- .github/workflows/golangci-lint.yml | 2 +- management/internals/shared/grpc/proxy.go | 1 + .../internals/shared/grpc/proxy_group_access_test.go | 10 +++++----- proxy/internal/k8s/lease.go | 2 +- proxy/internal/proxy/reverseproxy_test.go | 7 ++++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 19a3a01e0..43a285f40 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -20,7 +20,7 @@ jobs: uses: codespell-project/actions-codespell@v2 with: ignore_words_list: erro,clienta,hastable,iif,groupd,testin,groupe,cros,ans - skip: go.mod,go.sum + skip: go.mod,go.sum,proxy/web golangci: strategy: fail-fast: false diff --git a/management/internals/shared/grpc/proxy.go b/management/internals/shared/grpc/proxy.go index 62ede5e9f..269d6953e 100644 --- a/management/internals/shared/grpc/proxy.go +++ b/management/internals/shared/grpc/proxy.go @@ -845,6 +845,7 @@ func (s *ProxyServiceServer) ValidateSession(ctx context.Context, req *proto.Val "domain": domain, "error": err.Error(), }).Error("ValidateSession: decode public key") + //nolint:nilerr return &proto.ValidateSessionResponse{ Valid: false, DeniedReason: "invalid_service_config", diff --git a/management/internals/shared/grpc/proxy_group_access_test.go b/management/internals/shared/grpc/proxy_group_access_test.go index 523705d82..84fb54923 100644 --- a/management/internals/shared/grpc/proxy_group_access_test.go +++ b/management/internals/shared/grpc/proxy_group_access_test.go @@ -29,19 +29,19 @@ func (m *mockReverseProxyManager) GetGlobalServices(ctx context.Context) ([]*rev } func (m *mockReverseProxyManager) GetAllServices(ctx context.Context, accountID, userID string) ([]*reverseproxy.Service, error) { - return nil, nil + return []*reverseproxy.Service{}, nil } func (m *mockReverseProxyManager) GetService(ctx context.Context, accountID, userID, reverseProxyID string) (*reverseproxy.Service, error) { - return nil, nil + return &reverseproxy.Service{}, nil } func (m *mockReverseProxyManager) CreateService(ctx context.Context, accountID, userID string, rp *reverseproxy.Service) (*reverseproxy.Service, error) { - return nil, nil + return &reverseproxy.Service{}, nil } func (m *mockReverseProxyManager) UpdateService(ctx context.Context, accountID, userID string, rp *reverseproxy.Service) (*reverseproxy.Service, error) { - return nil, nil + return &reverseproxy.Service{}, nil } func (m *mockReverseProxyManager) DeleteService(ctx context.Context, accountID, userID, reverseProxyID string) error { @@ -65,7 +65,7 @@ func (m *mockReverseProxyManager) ReloadService(ctx context.Context, accountID, } func (m *mockReverseProxyManager) GetServiceByID(ctx context.Context, accountID, reverseProxyID string) (*reverseproxy.Service, error) { - return nil, nil + return &reverseproxy.Service{}, nil } func (m *mockReverseProxyManager) GetServiceIDByTargetID(_ context.Context, _, _ string) (string, error) { diff --git a/proxy/internal/k8s/lease.go b/proxy/internal/k8s/lease.go index c18721a2c..9677e0e27 100644 --- a/proxy/internal/k8s/lease.go +++ b/proxy/internal/k8s/lease.go @@ -151,7 +151,7 @@ func (c *LeaseClient) Get(ctx context.Context, name string) (*Lease, error) { defer func() { _ = resp.Body.Close() }() if resp.StatusCode == http.StatusNotFound { - return nil, nil + return nil, nil //nolint:nilnil } if resp.StatusCode != http.StatusOK { return nil, c.readError(resp) diff --git a/proxy/internal/proxy/reverseproxy_test.go b/proxy/internal/proxy/reverseproxy_test.go index 5d2447e5c..b34da008a 100644 --- a/proxy/internal/proxy/reverseproxy_test.go +++ b/proxy/internal/proxy/reverseproxy_test.go @@ -597,9 +597,9 @@ func TestRewriteLocationFunc(t *testing.T) { t.Run("re-adds stripped path prefix", func(t *testing.T) { resp, err := run(newProxy("https"), "/api", newReq("https://public.example.com/api/users"), "http://backend.internal:8080/users") - defer resp.Body.Close() require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, "https://public.example.com/api/users", resp.Header.Get("Location")) }) @@ -608,6 +608,7 @@ func TestRewriteLocationFunc(t *testing.T) { "http://backend.internal:8080/path") require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, "http://public.example.com/path", resp.Header.Get("Location")) }) @@ -615,6 +616,7 @@ func TestRewriteLocationFunc(t *testing.T) { resp, err := run(newProxy("https"), "", newReq("https://public.example.com/"), "") require.NoError(t, err) + defer resp.Body.Close() assert.Empty(t, resp.Header.Get("Location")) }) @@ -623,6 +625,7 @@ func TestRewriteLocationFunc(t *testing.T) { "http://backend.internal:8080/login") require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, "https://public.example.com/login", resp.Header.Get("Location")) }) @@ -633,6 +636,7 @@ func TestRewriteLocationFunc(t *testing.T) { "http://backend.internal:8080/login?redirect=%2Fdashboard&lang=en") require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, "https://public.example.com/login?redirect=%2Fdashboard&lang=en", resp.Header.Get("Location")) }) @@ -641,6 +645,7 @@ func TestRewriteLocationFunc(t *testing.T) { "http://backend.internal:8080/docs#section-2") require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, "https://public.example.com/docs#section-2", resp.Header.Get("Location")) })