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
+1 -1
View File
@@ -28,7 +28,7 @@ type BoltDBDriverParameters struct {
UseRelPaths bool
}
func NewBoltDBCache(parameters interface{}, log zlog.Logger) (*BoltDBDriver, error) {
func NewBoltDBCache(parameters any, log zlog.Logger) (*BoltDBDriver, error) {
properParameters, ok := parameters.(BoltDBDriverParameters)
if !ok {
log.Error().Err(zerr.ErrTypeAssertionFailed).Msgf("failed to cast type, expected type '%T' but got '%T'",
+8 -9
View File
@@ -2,6 +2,7 @@ package cache
import (
"context"
"slices"
"strings"
"github.com/aws/aws-sdk-go-v2/aws"
@@ -61,7 +62,7 @@ func (d *DynamoDBDriver) NewTable(tableName string) error {
return nil
}
func NewDynamoDBCache(parameters interface{}, log zlog.Logger) (*DynamoDBDriver, error) {
func NewDynamoDBCache(parameters any, log zlog.Logger) (*DynamoDBDriver, error) {
properParameters, ok := parameters.(DynamoDBDriverParameters)
if !ok {
log.Error().Err(zerr.ErrTypeAssertionFailed).Msgf("failed to cast type, expected type '%T' but got '%T'",
@@ -72,7 +73,7 @@ func NewDynamoDBCache(parameters interface{}, log zlog.Logger) (*DynamoDBDriver,
// custom endpoint resolver to point to localhost
customResolver := aws.EndpointResolverWithOptionsFunc( //nolint: staticcheck
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
func(service, region string, options ...any) (aws.Endpoint, error) {
return aws.Endpoint{ //nolint: staticcheck
PartitionID: "aws",
URL: properParameters.Endpoint,
@@ -116,7 +117,7 @@ func (d *DynamoDBDriver) Name() string {
return "dynamodb"
}
// Returns the original blob.
// GetBlob returns the original blob.
func (d *DynamoDBDriver) GetBlob(digest godigest.Digest) (string, error) {
resp, err := d.client.GetItem(context.TODO(), &dynamodb.GetItemInput{
TableName: aws.String(d.tableName),
@@ -231,10 +232,8 @@ func (d *DynamoDBDriver) HasBlob(digest godigest.Digest, path string) bool {
return true
}
for _, item := range out.DuplicateBlobPath {
if item == path {
return true
}
if slices.Contains(out.DuplicateBlobPath, path) {
return true
}
d.log.Debug().Err(zerr.ErrCacheMiss).Str("digest", string(digest)).Msg("failed to find blob in cache")
@@ -243,7 +242,7 @@ func (d *DynamoDBDriver) HasBlob(digest godigest.Digest, path string) bool {
}
func (d *DynamoDBDriver) DeleteBlob(digest godigest.Digest, path string) error {
marshaledKey, _ := attributevalue.MarshalMap(map[string]interface{}{"Digest": digest.String()})
marshaledKey, _ := attributevalue.MarshalMap(map[string]any{"Digest": digest.String()})
expression := "DELETE DuplicateBlobPath :i"
attrPath := types.AttributeValueMemberSS{Value: []string{path}}
@@ -322,7 +321,7 @@ func (d *DynamoDBDriver) putOriginBlob(digest godigest.Digest, path string) erro
func (d *DynamoDBDriver) updateItem(digest godigest.Digest, expression string,
expressionAttVals map[string]types.AttributeValue,
) error {
marshaledKey, _ := attributevalue.MarshalMap(map[string]interface{}{"Digest": digest.String()})
marshaledKey, _ := attributevalue.MarshalMap(map[string]any{"Digest": digest.String()})
_, err := d.client.UpdateItem(context.TODO(), &dynamodb.UpdateItemInput{
Key: marshaledKey,
+1 -1
View File
@@ -32,7 +32,7 @@ type RedisDriverParameters struct {
KeyPrefix string
}
func NewRedisCache(parameters interface{}, log zlog.Logger) (*RedisDriver, error) {
func NewRedisCache(parameters any, log zlog.Logger) (*RedisDriver, error) {
properParameters, ok := parameters.(RedisDriverParameters)
if !ok {
log.Error().Err(zerr.ErrTypeAssertionFailed).Msgf("failed to cast type, expected type '%T' but got '%T'",