From 039a5ec5af377232ff7e7a581927e2248c92d954 Mon Sep 17 00:00:00 2001 From: Carlo Teubner Date: Fri, 20 Dec 2024 16:30:24 +0000 Subject: [PATCH] golangci-lint: add wastedassign & update code This linter caught an oversight that is probably inconsequential, but it shows its potential to catch more serious oversights as well. Signed-off-by: Carlo Teubner --- .golangci.yml | 1 + pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go | 2 +- pkg/server/plugin/upstreamauthority/ejbca/ejbca.go | 2 +- pkg/server/plugin/upstreamauthority/vault/vault_test.go | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9306540caf..e941b749ad 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -23,6 +23,7 @@ linters: - unparam - whitespace - gocritic + - wastedassign - nolintlint linters-settings: diff --git a/pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go b/pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go index 9985cb3843..c29fdf8304 100644 --- a/pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go +++ b/pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go @@ -33,7 +33,7 @@ func createHelper(c *Plugin) ContainerHelper { rootDir = "/" } return &containerHelper{ - rootDir: c.rootDir, + rootDir: rootDir, } } diff --git a/pkg/server/plugin/upstreamauthority/ejbca/ejbca.go b/pkg/server/plugin/upstreamauthority/ejbca/ejbca.go index d023627b88..cdbc2b19f1 100644 --- a/pkg/server/plugin/upstreamauthority/ejbca/ejbca.go +++ b/pkg/server/plugin/upstreamauthority/ejbca/ejbca.go @@ -358,7 +358,7 @@ func (p *Plugin) setClient(client ejbcaClient) { func (p *Plugin) getEndEntityName(config *Config, csr *x509.CertificateRequest) (string, error) { logger := p.logger.Named("getEndEntityName") - eeName := "" + var eeName string // 1. If the endEntityName option is set, determine the end entity name based on the option // 2. If the endEntityName option is not set, determine the end entity name based on the CSR diff --git a/pkg/server/plugin/upstreamauthority/vault/vault_test.go b/pkg/server/plugin/upstreamauthority/vault/vault_test.go index 65f704f728..f99bf77fd5 100644 --- a/pkg/server/plugin/upstreamauthority/vault/vault_test.go +++ b/pkg/server/plugin/upstreamauthority/vault/vault_test.go @@ -179,7 +179,7 @@ func TestConfigure(t *testing.T) { return v, ok } - plainConfig := "" + var plainConfig string if tt.plainConfig != "" { plainConfig = tt.plainConfig } else {