diff --git a/action/action.go b/action/action.go index 69292d30..0156a2ad 100644 --- a/action/action.go +++ b/action/action.go @@ -144,6 +144,7 @@ func (a Action) saveLogs(logFile *os.File, opResult driver.OperationResult) erro _, logOutputNameInUse := opResult.Outputs[claim.OutputInvocationImageLogs] if logOutputNameInUse { // The bundle is using our reserved log output name, so skip saving the logs + return nil } // Read from the beginning of the file @@ -152,7 +153,7 @@ func (a Action) saveLogs(logFile *os.File, opResult driver.OperationResult) erro return errors.Wrapf(err, "error seeking the log file") } - logsB, err := ioutil.ReadAll(logFile) + logsB, err := io.ReadAll(logFile) if err != nil { return errors.Wrapf(err, "error reading log file %s", logFile.Name()) } diff --git a/action/operation_configs_test.go b/action/operation_configs_test.go index 70044f98..653132a6 100644 --- a/action/operation_configs_test.go +++ b/action/operation_configs_test.go @@ -2,7 +2,7 @@ package action import ( "errors" - "io/ioutil" + "io" "os" "testing" @@ -24,6 +24,7 @@ func TestOperationConfigs_ApplyConfig(t *testing.T) { t.Run("all config is persisted", func(t *testing.T) { a := OperationConfigs{ + //nolint:all func(op *driver.Operation) error { if op.Files == nil { op.Files = make(map[string]string, 1) @@ -31,8 +32,9 @@ func TestOperationConfigs_ApplyConfig(t *testing.T) { op.Files["a"] = "b" return nil }, + //nolint:all func(op *driver.Operation) error { - op.Out = ioutil.Discard + op.Out = io.Discard return nil }, } @@ -40,7 +42,7 @@ func TestOperationConfigs_ApplyConfig(t *testing.T) { err := a.ApplyConfig(op) require.NoError(t, err, "ApplyConfig should not have returned an error") assert.Contains(t, op.Files, "a", "Changes from the first config function were not persisted") - assert.Equal(t, ioutil.Discard, op.Out, "Changes from the second config function were not persisted") + assert.Equal(t, io.Discard, op.Out, "Changes from the second config function were not persisted") assert.Equal(t, os.Stderr, op.Err, "Changes from the second config function were not persisted") }) @@ -50,7 +52,7 @@ func TestOperationConfigs_ApplyConfig(t *testing.T) { return errors.New("oops") }, func(op *driver.Operation) error { - op.Out = ioutil.Discard + op.Out = io.Discard return nil }, } diff --git a/bundle/definition/validators.go b/bundle/definition/validators.go index cd5071a5..a6e182be 100644 --- a/bundle/definition/validators.go +++ b/bundle/definition/validators.go @@ -1,3 +1,4 @@ +//nolint:unused,revive package definition import ( diff --git a/claim/claim_test.go b/claim/claim_test.go index ee51a8fa..f05855ed 100644 --- a/claim/claim_test.go +++ b/claim/claim_test.go @@ -297,6 +297,7 @@ func TestClaims_Sort(t *testing.T) { assert.Equal(t, "3", c[2].ID, "Claims did not sort 3 to the third slot") } +//nolint:all func TestNewULID_ThreadSafe(t *testing.T) { // Validate that the ULID function is thread-safe and generates // monotonically increasing values diff --git a/claim/output_test.go b/claim/output_test.go index 63b4bbd4..1f682ec8 100644 --- a/claim/output_test.go +++ b/claim/output_test.go @@ -42,13 +42,11 @@ func TestOutput(t *testing.T) { assert.Equal(t, []string{ActionInstall}, def.ApplyTo) } -func TestOutputs_GetByName(t *testing.T) { +// func TestOutputs_GetByName(t *testing.T) { +// } -} - -func TestOutputs_GetByIndex(t *testing.T) { - -} +// func TestOutputs_GetByIndex(t *testing.T) { +// } func TestOutputs_Sort(t *testing.T) { o := NewOutputs([]Output{ diff --git a/driver/debug/debug.go b/driver/debug/debug.go index c304b10c..11cfa601 100644 --- a/driver/debug/debug.go +++ b/driver/debug/debug.go @@ -29,7 +29,7 @@ func (d *Driver) Run(op *driver.Operation) (driver.OperationResult, error) { } // Handles always returns true, effectively claiming to work for any image type -func (d *Driver) Handles(dt string) bool { +func (d *Driver) Handles(_ string) bool { return true } diff --git a/driver/kubernetes/kubernetes.go b/driver/kubernetes/kubernetes.go index d98c050d..28ea2896 100644 --- a/driver/kubernetes/kubernetes.go +++ b/driver/kubernetes/kubernetes.go @@ -570,7 +570,7 @@ func (k *Driver) watchJobStatusAndLogs(ctx context.Context, podSelector metav1.L complete := false for _, cond := range job.Status.Conditions { if cond.Type == batchv1.JobFailed { - err = fmt.Errorf(cond.Message) + err = fmt.Errorf("%s", cond.Message) complete = true break } diff --git a/golangci.yml b/golangci.yml index 340b068e..e9968cba 100644 --- a/golangci.yml +++ b/golangci.yml @@ -16,3 +16,9 @@ linters: linters-settings: goimports: local-prefixes: github.com/cnabio/cnab-go + +issues: + exclude-rules: + - path: _test.go + linters: + - revive \ No newline at end of file diff --git a/imagestore/remote/remote.go b/imagestore/remote/remote.go index d2d6f4ba..3a3ceb4e 100644 --- a/imagestore/remote/remote.go +++ b/imagestore/remote/remote.go @@ -22,7 +22,7 @@ func Create(options ...imagestore.Option) (imagestore.Store, error) { }, nil } -func (r *remote) Add(im string) (string, error) { +func (r *remote) Add(_ string) (string, error) { return "", nil } diff --git a/packager/export_test.go b/packager/export_test.go index c8065f8b..69b5f239 100644 --- a/packager/export_test.go +++ b/packager/export_test.go @@ -1,7 +1,6 @@ package packager import ( - "io/ioutil" "os" "path/filepath" "reflect" @@ -149,7 +148,7 @@ func TestExportDigestMismatch(t *testing.T) { }() is := &imagestoremocks.MockStore{ - AddStub: func(im string) (string, error) { + AddStub: func(_ string) (string, error) { // return the same digest for all images, but only one of them has a digest in the bundle manifest so just // that one will fail verification return "sha256:222222228fb14266b7c0461ef1ef0b2f8c05f41cd544987a259a9d92cdad2540", nil @@ -174,7 +173,7 @@ func TestExportDigestMismatch(t *testing.T) { } func setupTempDir() (string, error) { - tempDir, err := ioutil.TempDir("", "duffle-export-test") + tempDir, err := os.MkdirTemp("", "duffle-export-test") if err != nil { return "", err } @@ -182,7 +181,7 @@ func setupTempDir() (string, error) { } func setupPWD() (string, string, error) { - tempPWD, err := ioutil.TempDir("", "duffle-export-test") + tempPWD, err := os.MkdirTemp("", "duffle-export-test") if err != nil { return "", "", err }