Skip to content

Bump golangci-lint to v2#791

Merged
andypitcher merged 5 commits into
rancher:mainfrom
andypitcher:update-golangci-lint-version
Apr 14, 2025
Merged

Bump golangci-lint to v2#791
andypitcher merged 5 commits into
rancher:mainfrom
andypitcher:update-golangci-lint-version

Conversation

@andypitcher
Copy link
Copy Markdown
Contributor

@andypitcher andypitcher commented Apr 1, 2025

Resolved renovate PR:

Description:

The golanci-lint v1 is getting deprecated and golangci-lint advises to go to v2. Thus, we need to update the configuration format.
As of v2, we can use golangci-lint migrate to migrate the .golangci.yaml configuration from v1 to v2.

Related error:

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/product/migration-guide for migration instructions
Failed executing command with error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/product/migration-guide for migration instructions
make: *** [validate-go] Error 3

Major changes:

  • Bump golangci-lint to v2.0.2 and migrate golangci conf from json to yaml and v2 format
  • Add gosec linter and fixes several issues. One of them has been whitelisted for the time being, will be worked on through another PR.
  • unused and revive were omitted since they were returning several errors. They will be handled through another PR.

…ieldValue

	*Added empty slice check
	*pkg/condition/condition.go:246:29: G602: slice index out of range (gosec)
		field := v.FieldByName(name[0])
…or less

	*pkg/crds/crd.go:40:9: G306: Expect WriteFile permissions to be 0600 or less (gosec)
		err = os.WriteFile(filename, yamlBytes, 0o644)
…eOldClusterScanReports

	*pkg/securityscan/jobHandler.go:72:5: G104: Errors unhandled (gosec)
		c.rescheduleScan(scan)
	*pkg/securityscan/jobHandler.go:73:5: G104: Errors unhandled (gosec)
		c.purgeOldClusterScanReports(scan)
@andypitcher andypitcher force-pushed the update-golangci-lint-version branch from 40d7659 to d1da33d Compare April 2, 2025 08:30
@andypitcher andypitcher marked this pull request as ready for review April 2, 2025 08:35
@andypitcher andypitcher requested review from a team as code owners April 2, 2025 08:35
@andypitcher andypitcher requested a review from pjbgf April 2, 2025 08:35
Copy link
Copy Markdown
Contributor

@vardhaman22 vardhaman22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one question. overall LGTM

Comment thread pkg/crds/crd.go
Comment thread pkg/securityscan/jobHandler.go
@andypitcher andypitcher merged commit 6a85b30 into rancher:main Apr 14, 2025
@andypitcher andypitcher deleted the update-golangci-lint-version branch April 14, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants