From 2939d3c6b9be3590273a2225e94f0e3a185d1d9b Mon Sep 17 00:00:00 2001 From: Binbin Li Date: Mon, 2 Dec 2024 06:54:54 +0000 Subject: [PATCH] chore: bump up golangci-lint version Signed-off-by: Binbin Li --- .github/workflows/golangci-lint.yml | 2 +- cmd/ratify/cmd/serve.go | 2 +- pkg/certificateprovider/certificate_provider_test.go | 2 +- pkg/controllers/logging.go | 2 +- pkg/keymanagementprovider/keymanagementprovider_test.go | 2 +- pkg/manager/manager.go | 2 +- pkg/verifier/notation/truststore_test.go | 2 +- pkg/verifier/result_test.go | 7 ++++--- pkg/verifier/types/types_test.go | 7 ++++--- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 7d903f64d..54319e002 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -26,5 +26,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 with: - version: v1.59.1 + version: v1.62.2 args: --timeout=10m diff --git a/cmd/ratify/cmd/serve.go b/cmd/ratify/cmd/serve.go index ab0f872f0..373ad12ef 100644 --- a/cmd/ratify/cmd/serve.go +++ b/cmd/ratify/cmd/serve.go @@ -118,7 +118,7 @@ func serve(opts serveCmdOptions) error { if err != nil { return err } - logrus.Infof("starting server at" + opts.httpServerAddress) + logrus.Infof("starting server at %s", opts.httpServerAddress) if err := server.Run(nil); err != nil { return err } diff --git a/pkg/certificateprovider/certificate_provider_test.go b/pkg/certificateprovider/certificate_provider_test.go index 78d70c439..2b6309be4 100644 --- a/pkg/certificateprovider/certificate_provider_test.go +++ b/pkg/certificateprovider/certificate_provider_test.go @@ -78,7 +78,7 @@ func TestDecodeCertificates_ByteArrayToCertificates(t *testing.T) { r, err := DecodeCertificates(c1) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } expectedLen := 1 diff --git a/pkg/controllers/logging.go b/pkg/controllers/logging.go index 7ad3429f6..90abce740 100644 --- a/pkg/controllers/logging.go +++ b/pkg/controllers/logging.go @@ -122,7 +122,7 @@ func (sink *LogrusSink) createEntry(keysAndValues ...interface{}) *logrus.Entry } func (sink *LogrusSink) formatMessage(msg string) string { - if sink.names == nil || len(sink.names) == 0 { + if len(sink.names) == 0 { return msg } diff --git a/pkg/keymanagementprovider/keymanagementprovider_test.go b/pkg/keymanagementprovider/keymanagementprovider_test.go index 57a2828ee..c4ac13866 100644 --- a/pkg/keymanagementprovider/keymanagementprovider_test.go +++ b/pkg/keymanagementprovider/keymanagementprovider_test.go @@ -85,7 +85,7 @@ func TestDecodeCertificates_ByteArrayToCertificates(t *testing.T) { r, err := DecodeCertificates(c1) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } expectedLen := 1 diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index f284ceaea..6726f39cd 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -105,7 +105,7 @@ func StartServer(httpServerAddress, configFilePath, certDirectory, caCertFile st logrus.Errorf("initialize server failed with error %v, exiting..", err) os.Exit(1) } - logrus.Infof("starting server at" + httpServerAddress) + logrus.Infof("starting server at %s", httpServerAddress) if err := server.Run(certRotatorReady); err != nil { logrus.Errorf("starting server failed with error %v, exiting..", err) os.Exit(1) diff --git a/pkg/verifier/notation/truststore_test.go b/pkg/verifier/notation/truststore_test.go index eb64c042d..964f97cb6 100644 --- a/pkg/verifier/notation/truststore_test.go +++ b/pkg/verifier/notation/truststore_test.go @@ -133,7 +133,7 @@ func TestGetCertificates_ErrorFromKMPReconcile(t *testing.T) { } store, err := newTrustStore(nil, certStore) if err != nil { - t.Fatalf("failed to parse verificationCertStores: " + err.Error()) + t.Fatalf("failed to parse verificationCertStores: %s", err.Error()) } controllers.NamespacedCertStores = &mockCertStores{ diff --git a/pkg/verifier/result_test.go b/pkg/verifier/result_test.go index 64efd2c52..67ceec690 100644 --- a/pkg/verifier/result_test.go +++ b/pkg/verifier/result_test.go @@ -16,9 +16,10 @@ limitations under the License. package verifier import ( - "fmt" "testing" + e "errors" + "github.com/ratify-project/ratify/errors" ) @@ -47,7 +48,7 @@ func TestNewVerifierResult(t *testing.T) { { name: "error without detail", message: testMsg1, - err: errors.ErrorCodeUnknown.WithError(fmt.Errorf(testErrReason)).WithRemediation(testRemediation), + err: errors.ErrorCodeUnknown.WithError(e.New(testErrReason)).WithRemediation(testRemediation), expectedMsg: testMsg1, expectedErrReason: testErrReason, expectedRemediation: testRemediation, @@ -55,7 +56,7 @@ func TestNewVerifierResult(t *testing.T) { { name: "error with detail", message: testMsg1, - err: errors.ErrorCodeUnknown.WithError(fmt.Errorf(testErrReason)).WithRemediation(testRemediation).WithDetail(testMsg2), + err: errors.ErrorCodeUnknown.WithError(e.New(testErrReason)).WithRemediation(testRemediation).WithDetail(testMsg2), expectedMsg: testMsg2, expectedErrReason: testErrReason, expectedRemediation: testRemediation, diff --git a/pkg/verifier/types/types_test.go b/pkg/verifier/types/types_test.go index ce1cd39f6..c2d097a33 100644 --- a/pkg/verifier/types/types_test.go +++ b/pkg/verifier/types/types_test.go @@ -16,9 +16,10 @@ limitations under the License. package types import ( - "fmt" "testing" + e "errors" + "github.com/ratify-project/ratify/errors" ) @@ -47,7 +48,7 @@ func TestCreateVerifierResult(t *testing.T) { { name: "error without detail", message: testMsg1, - err: errors.ErrorCodeUnknown.WithError(fmt.Errorf(testErrReason)).WithRemediation(testRemediation), + err: errors.ErrorCodeUnknown.WithError(e.New(testErrReason)).WithRemediation(testRemediation), expectedMsg: testMsg1, expectedErrReason: testErrReason, expectedRemediation: testRemediation, @@ -55,7 +56,7 @@ func TestCreateVerifierResult(t *testing.T) { { name: "error with detail", message: testMsg1, - err: errors.ErrorCodeUnknown.WithError(fmt.Errorf(testErrReason)).WithRemediation(testRemediation).WithDetail(testMsg2), + err: errors.ErrorCodeUnknown.WithError(e.New(testErrReason)).WithRemediation(testRemediation).WithDetail(testMsg2), expectedMsg: testMsg2, expectedErrReason: testErrReason, expectedRemediation: testRemediation,