From f83529dead65ab16f2afd20dc7d8b68dbce6bf0c Mon Sep 17 00:00:00 2001 From: Anish Ramasekar Date: Wed, 2 Oct 2024 14:17:26 -0500 Subject: [PATCH] chore: bump golangci-lint to v1.61.0 Signed-off-by: Anish Ramasekar --- .golangci.yml | 8 ++++++++ Makefile | 4 ++-- pkg/cmd/podidentity/detect.go | 8 ++++---- pkg/webhook/consts.go | 2 +- pkg/webhook/webhook.go | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a53c5c9fc..cdeaa8888 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,6 +28,14 @@ linters: # Run with --fast=false for more extensive checks fast: true +issues: + # default: 50 + max-issues-per-linter: 0 + exclude-rules: + - text: "unused-parameter: parameter '.*' seems to be unused, consider removing or renaming it as _" + linters: + - revive + linters-settings: goimports: local-prefixes: github.com/Azure/azure-workload-identity diff --git a/Makefile b/Makefile index 89e53ab23..ec16ec5a6 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ KUSTOMIZE_VER := v4.1.2 KUSTOMIZE_BIN := kustomize KUSTOMIZE := $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER) -GOLANGCI_LINT_VER := v1.52.2 +GOLANGCI_LINT_VER := v1.61.0 GOLANGCI_LINT_BIN := golangci-lint GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER) @@ -365,7 +365,7 @@ clean: .PHONY: lint lint: $(GOLANGCI_LINT) - $(GOLANGCI_LINT) run -v + $(GOLANGCI_LINT) run -v --timeout 5m .PHONY: helm-lint helm-lint: $(HELM) diff --git a/pkg/cmd/podidentity/detect.go b/pkg/cmd/podidentity/detect.go index df5334fcd..ceed593c7 100644 --- a/pkg/cmd/podidentity/detect.go +++ b/pkg/cmd/podidentity/detect.go @@ -60,7 +60,7 @@ func init() { type detectCmd struct { namespace string outputDir string - proxyPort int + proxyPort int32 serviceAccountTokenExpiration time.Duration tenantID string kubeClient client.Client @@ -85,7 +85,7 @@ func newDetectCmd() *cobra.Command { f := cmd.Flags() f.StringVar(&detectCmd.namespace, "namespace", "default", "Namespace to detect the configuration") f.StringVarP(&detectCmd.outputDir, "output-dir", "o", "", "Output directory to write the configuration files") - f.IntVarP(&detectCmd.proxyPort, "proxy-port", "p", 8000, "Proxy port to use for the proxy container") + f.Int32VarP(&detectCmd.proxyPort, "proxy-port", "p", 8000, "Proxy port to use for the proxy container") f.DurationVar(&detectCmd.serviceAccountTokenExpiration, options.ServiceAccountTokenExpiration.Flag, time.Duration(webhook.DefaultServiceAccountTokenExpiration)*time.Second, options.ServiceAccountTokenExpiration.Description) f.StringVar(&detectCmd.tenantID, "tenant-id", "", "Managed identity tenant id. If specified, the tenant id will be set as an annotation on the service account.") @@ -349,7 +349,7 @@ func (dc *detectCmd) addProxyInitContainer(initContainers []corev1.Container) [] Env: []corev1.EnvVar{ { Name: "PROXY_PORT", - Value: strconv.Itoa(dc.proxyPort), + Value: strconv.FormatInt(int64(dc.proxyPort), 10), }, }, } @@ -381,7 +381,7 @@ func (dc *detectCmd) addProxyContainer(containers []corev1.Container) []corev1.C }, Ports: []corev1.ContainerPort{ { - ContainerPort: int32(dc.proxyPort), + ContainerPort: dc.proxyPort, }, }, Lifecycle: &corev1.Lifecycle{ diff --git a/pkg/webhook/consts.go b/pkg/webhook/consts.go index 6dc2128cd..e88cee916 100644 --- a/pkg/webhook/consts.go +++ b/pkg/webhook/consts.go @@ -28,7 +28,7 @@ const ( // This is the Kubernetes default value for projected service account token DefaultServiceAccountTokenExpiration = int64(3600) // DefaultProxySidecarPort is the default port for proxy sidecar - DefaultProxySidecarPort = int32(8000) + DefaultProxySidecarPort = 8000 ) const ( diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go index ca2e3ca41..830edda17 100644 --- a/pkg/webhook/webhook.go +++ b/pkg/webhook/webhook.go @@ -334,7 +334,7 @@ func getProxyPort(pod *corev1.Pod) (int32, error) { return 0, errors.Wrap(err, "failed to parse proxy sidecar port") } - return int32(parsed), nil + return int32(parsed), nil //nolint:gosec // disable G115 } func validServiceAccountTokenExpiry(tokenExpiry int64) bool {