mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
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:
@@ -1,5 +1,4 @@
|
||||
//go:build imagetrust
|
||||
// +build imagetrust
|
||||
|
||||
package imagetrust
|
||||
|
||||
@@ -117,7 +116,6 @@ func VerifyCosignSignature(
|
||||
|
||||
err = verifier.VerifySignature(bytes.NewReader(signature), bytes.NewReader(payload),
|
||||
options.WithContext(context.Background()))
|
||||
|
||||
if err == nil {
|
||||
return string(pubKeyContent), true, nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build imagetrust
|
||||
// +build imagetrust
|
||||
|
||||
package imagetrust
|
||||
|
||||
@@ -92,7 +91,7 @@ func NewAWSImageTrustStore(region, endpoint string) (*ImageTrustStore, error) {
|
||||
|
||||
func GetSecretsManagerClient(region, endpoint string) (*secretsmanager.Client, error) {
|
||||
customResolver := aws.EndpointResolverWithOptionsFunc( //nolint: staticcheck
|
||||
func(service, region string, options ...interface{}) (aws.Endpoint, error) { //nolint: staticcheck
|
||||
func(service, region string, options ...any) (aws.Endpoint, error) { //nolint: staticcheck
|
||||
return aws.Endpoint{ //nolint: staticcheck
|
||||
PartitionID: "aws",
|
||||
URL: endpoint,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build !imagetrust
|
||||
// +build !imagetrust
|
||||
|
||||
package imagetrust
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build imagetrust
|
||||
// +build imagetrust
|
||||
|
||||
package imagetrust_test
|
||||
|
||||
@@ -648,7 +647,7 @@ func TestLocalTrustStore(t *testing.T) {
|
||||
imageTrustStore, err := imagetrust.NewLocalImageTrustStore(rootDir)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
var dbDriverParams map[string]interface{}
|
||||
var dbDriverParams map[string]any
|
||||
|
||||
RunUploadTests(t, *imageTrustStore)
|
||||
RunVerificationTests(t, dbDriverParams)
|
||||
@@ -664,7 +663,7 @@ func TestLocalTrustStoreRedis(t *testing.T) {
|
||||
imageTrustStore, err := imagetrust.NewLocalImageTrustStore(rootDir)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
dbDriverParams := map[string]interface{}{
|
||||
dbDriverParams := map[string]any{
|
||||
"name": "redis",
|
||||
"url": "redis://" + miniRedis.Addr(),
|
||||
}
|
||||
@@ -1094,7 +1093,7 @@ func TestAWSTrustStore(t *testing.T) {
|
||||
imageMetaTablename := "imageMetaTable" + uuid.String()
|
||||
repoBlobsInfoTablename := "repoBlobsInfoTable" + uuid.String()
|
||||
|
||||
dynamoDBDriverParams := map[string]interface{}{
|
||||
dynamoDBDriverParams := map[string]any{
|
||||
"name": "dynamodb",
|
||||
"endpoint": os.Getenv("DYNAMODBMOCK_ENDPOINT"),
|
||||
"region": "us-east-2",
|
||||
@@ -1205,7 +1204,7 @@ func RunUploadTests(t *testing.T, imageTrustStore imagetrust.ImageTrustStore) {
|
||||
})
|
||||
}
|
||||
|
||||
func RunVerificationTests(t *testing.T, dbDriverParams map[string]interface{}) { //nolint: thelper
|
||||
func RunVerificationTests(t *testing.T, dbDriverParams map[string]any) { //nolint: thelper
|
||||
Convey("verify signatures are trusted", func() {
|
||||
defaultValue := true
|
||||
rootDir := t.TempDir()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build imagetrust
|
||||
// +build imagetrust
|
||||
|
||||
package imagetrust
|
||||
|
||||
@@ -211,7 +210,7 @@ func (cloud *CertificateAWSStorage) recreateSecret(secretInputParam *secretsmana
|
||||
|
||||
var err error
|
||||
|
||||
for i := 0; i < maxAttempts; i++ {
|
||||
for range maxAttempts {
|
||||
_, err = cloud.secretsManagerClient.CreateSecret(context.Background(), secretInputParam)
|
||||
if err == nil {
|
||||
return nil
|
||||
@@ -286,7 +285,8 @@ func (cloud *CertificateAWSStorage) GetCertificates(
|
||||
return certificates, nil
|
||||
}
|
||||
|
||||
// Equivalent function for trustpolicy.LoadDocument() but using a specific SysFS not the one returned by ConfigFS().
|
||||
// LoadTrustPolicyDocument is equivalent to trustpolicy.LoadDocument() but using a specific SysFS
|
||||
// not the one returned by ConfigFS().
|
||||
func (local *CertificateLocalStorage) LoadTrustPolicyDocument() (*trustpolicy.Document, error) {
|
||||
notationDir, err := local.GetNotationDirPath()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user