chore: update golangci-lint and fix all issues (#3575)

* chore: Update golangci-lint

Signed-off-by: Lars Francke <git@lars-francke.de>

* chore: fix all golangci-lint issues

- Remove deprecated `// +build` tags
- Fix godoclint, modernize, wsl_v5, govet, lll, gci, noctx issues
- Update linter configuration
- Modernize code to use Go 1.22+ features (for range N, slices.Contains, etc.)
- Update make check lint the privileged tests

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

---------

Signed-off-by: Lars Francke <git@lars-francke.de>
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Co-authored-by: Lars Francke <git@lars-francke.de>
This commit is contained in:
Andrei Aaron
2025-11-22 23:36:48 +02:00
committed by GitHub
parent 566286ae42
commit da426850e7
242 changed files with 811 additions and 1010 deletions
+6 -5
View File
@@ -3,6 +3,7 @@ package retention
import (
"context"
"fmt"
"slices"
glob "github.com/bmatcuk/doublestar/v4"
ispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -115,7 +116,7 @@ func (p policyManager) GetRetainedTagsFromIndex(ctx context.Context, repo string
for _, retainCandidate := range candidates.candidates {
// there may be duplicates
if !zcommon.Contains(retainTags, retainCandidate.Tag) {
if !slices.Contains(retainTags, retainCandidate.Tag) {
reason := fmt.Sprintf(retainedStrFormat, retainCandidate.RetainedBy)
logAction(repo, "keep", reason, retainCandidate, p.config.DryRun, &p.log)
@@ -127,7 +128,7 @@ func (p policyManager) GetRetainedTagsFromIndex(ctx context.Context, repo string
// log tags which will be removed
for _, candidate := range candidates {
if !zcommon.Contains(retainTags, candidate.Tag) {
if !slices.Contains(retainTags, candidate.Tag) {
logAction(repo, "delete", filteredByTagNames, candidate, p.config.DryRun, &p.log)
if p.auditLog != nil {
@@ -207,7 +208,7 @@ func (p policyManager) GetRetainedTagsFromMetaDB(ctx context.Context, repoMeta m
for _, retainCandidate := range retainCandidates {
// there may be duplicates
if !zcommon.Contains(retainTags, retainCandidate.Tag) {
if !slices.Contains(retainTags, retainCandidate.Tag) {
// format reason log msg
reason := fmt.Sprintf(retainedStrFormat, retainCandidate.RetainedBy)
@@ -220,9 +221,9 @@ func (p policyManager) GetRetainedTagsFromMetaDB(ctx context.Context, repoMeta m
// log tags which will be removed
for _, candidateInfo := range candidates {
if !zcommon.Contains(retainTags, candidateInfo.Tag) {
if !slices.Contains(retainTags, candidateInfo.Tag) {
var reason string
if zcommon.Contains(matchedByName, candidateInfo.Tag) {
if slices.Contains(matchedByName, candidateInfo.Tag) {
reason = filteredByTagRules
} else {
reason = filteredByTagNames
+2 -8
View File
@@ -93,10 +93,7 @@ func (lp latestPull) Perform(candidates []*types.Candidate) []*types.Candidate {
})
// take top count candidates
upper := lp.count
if lp.count > len(candidates) {
upper = len(candidates)
}
upper := min(lp.count, len(candidates))
candidates = candidates[:upper]
@@ -125,10 +122,7 @@ func (lp latestPush) Perform(candidates []*types.Candidate) []*types.Candidate {
})
// take top count candidates
upper := lp.count
if lp.count > len(candidates) {
upper = len(candidates)
}
upper := min(lp.count, len(candidates))
candidates = candidates[:upper]