From ad778e87bb93d328ac7a1430f15b598ec085ab0f Mon Sep 17 00:00:00 2001 From: Tommaso Sardelli Date: Thu, 19 May 2022 15:27:01 +0200 Subject: [PATCH] chore: upgrade golangci-lint to v1.46.2 (#9448) * chore: upgrade golangci-lint to v1.46.2 Because: * Installation of golangci-lint v1.45.2 is currently broken and fails silently due to a redacted dependency (https://github.com/blizzy78/varnamelen/issues/13) This commit: * Upgrades golangci-lint to v1.46.2 Signed-off-by: Tommaso Sardelli * fix: lint Signed-off-by: Michael Crenshaw * fix: lint Signed-off-by: Tommaso Sardelli Co-authored-by: Michael Crenshaw Signed-off-by: Michael Crenshaw --- .github/workflows/ci-build.yaml | 6 +++--- hack/installers/install-lint-tools.sh | 2 +- server/server.go | 1 + server/server_test.go | 11 ++++------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-build.yaml b/.github/workflows/ci-build.yaml index ab23abcc3644..ccdb1fa5c228 100644 --- a/.github/workflows/ci-build.yaml +++ b/.github/workflows/ci-build.yaml @@ -72,10 +72,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Run golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: - version: v1.38.0 - args: --timeout 10m --exclude SA5011 + version: v1.46.2 + args: --timeout 10m --exclude SA5011 --verbose test-go: name: Run unit tests for Go packages diff --git a/hack/installers/install-lint-tools.sh b/hack/installers/install-lint-tools.sh index 4c9bc3bb1305..a77e67c6fb0c 100755 --- a/hack/installers/install-lint-tools.sh +++ b/hack/installers/install-lint-tools.sh @@ -1,4 +1,4 @@ #!/bin/bash set -eux -o pipefail -GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.38.0 +GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2 diff --git a/server/server.go b/server/server.go index 7b4715c494be..79e2e8cdccab 100644 --- a/server/server.go +++ b/server/server.go @@ -950,6 +950,7 @@ func (a *ArgoCDServer) Authenticate(ctx context.Context) (context.Context, error if !argoCDSettings.AnonymousUserEnabled { return ctx, claimsErr } else { + // nolint:staticcheck ctx = context.WithValue(ctx, "claims", "") } } diff --git a/server/server_test.go b/server/server_test.go index 6c89e323bd8f..5fed08b81a6b 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -504,7 +504,7 @@ func getTestServer(t *testing.T, anonymousEnabled bool, withFakeSSO bool) (argoc cm.Data["users.anonymous.enabled"] = "true" } ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - return // Start with a placeholder. We need the server URL before setting up the real handler. + // Start with a placeholder. We need the server URL before setting up the real handler. })) ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { dexMockHandler(t, ts.URL)(w, r) @@ -597,12 +597,11 @@ func TestAuthenticate_3rd_party_JWTs(t *testing.T) { t.Parallel() argocd, dexURL := getTestServer(t, testDataCopy.anonymousEnabled, true) - ctx := context.Background() testDataCopy.claims.Issuer = fmt.Sprintf("%s/api/dex", dexURL) token := jwt.NewWithClaims(jwt.SigningMethodHS256, testDataCopy.claims) tokenString, err := token.SignedString([]byte("key")) require.NoError(t, err) - ctx = metadata.NewIncomingContext(context.Background(), metadata.Pairs(apiclient.MetaDataTokenKey, tokenString)) + ctx := metadata.NewIncomingContext(context.Background(), metadata.Pairs(apiclient.MetaDataTokenKey, tokenString)) ctx, err = argocd.Authenticate(ctx) claims := ctx.Value("claims") @@ -692,11 +691,10 @@ func TestAuthenticate_no_SSO(t *testing.T) { t.Parallel() argocd, dexURL := getTestServer(t, testDataCopy.anonymousEnabled, false) - ctx := context.Background() token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{Issuer: fmt.Sprintf("%s/api/dex", dexURL)}) tokenString, err := token.SignedString([]byte("key")) require.NoError(t, err) - ctx = metadata.NewIncomingContext(context.Background(), metadata.Pairs(apiclient.MetaDataTokenKey, tokenString)) + ctx := metadata.NewIncomingContext(context.Background(), metadata.Pairs(apiclient.MetaDataTokenKey, tokenString)) ctx, err = argocd.Authenticate(ctx) claims := ctx.Value("claims") @@ -798,8 +796,7 @@ func TestAuthenticate_bad_request_metadata(t *testing.T) { t.Parallel() argocd, _ := getTestServer(t, testDataCopy.anonymousEnabled, true) - ctx := context.Background() - ctx = metadata.NewIncomingContext(context.Background(), testDataCopy.metadata) + ctx := metadata.NewIncomingContext(context.Background(), testDataCopy.metadata) ctx, err := argocd.Authenticate(ctx) claims := ctx.Value("claims")