From d2feb1d819f7038899d7721d015da7da30271076 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Mon, 1 May 2023 11:43:45 -0700 Subject: [PATCH] Fix a few lint issues --- cmd/crane/cmd/catalog.go | 2 +- pkg/authn/keychain_test.go | 2 +- pkg/crane/push.go | 2 +- pkg/legacy/tarball/write.go | 5 +---- pkg/v1/daemon/image_test.go | 2 +- pkg/v1/daemon/write_test.go | 4 ++-- pkg/v1/google/list_test.go | 2 +- pkg/v1/remote/transport/error_test.go | 2 +- pkg/v1/remote/transport/retry_test.go | 2 +- pkg/v1/remote/write.go | 5 +---- pkg/v1/stream/layer_test.go | 5 +---- pkg/v1/tarball/image.go | 6 +++--- 12 files changed, 15 insertions(+), 24 deletions(-) diff --git a/cmd/crane/cmd/catalog.go b/cmd/crane/cmd/catalog.go index 9fa4abffc..e7dc91468 100644 --- a/cmd/crane/cmd/catalog.go +++ b/cmd/crane/cmd/catalog.go @@ -26,7 +26,7 @@ import ( ) // NewCmdCatalog creates a new cobra.Command for the catalog subcommand. -func NewCmdCatalog(options *[]crane.Option, argv ...string) *cobra.Command { +func NewCmdCatalog(options *[]crane.Option, _ ...string) *cobra.Command { var fullRef bool cmd := &cobra.Command{ Use: "catalog REGISTRY", diff --git a/pkg/authn/keychain_test.go b/pkg/authn/keychain_test.go index f983a4dec..fa3a75155 100644 --- a/pkg/authn/keychain_test.go +++ b/pkg/authn/keychain_test.go @@ -399,7 +399,7 @@ type fakeKeychain struct { count int } -func (k *fakeKeychain) Resolve(target Resource) (Authenticator, error) { +func (k *fakeKeychain) Resolve(_ Resource) (Authenticator, error) { k.count++ return k.auth, k.err } diff --git a/pkg/crane/push.go b/pkg/crane/push.go index 6d1fbd6ce..90a058502 100644 --- a/pkg/crane/push.go +++ b/pkg/crane/push.go @@ -25,7 +25,7 @@ import ( // Load reads the tarball at path as a v1.Image. func Load(path string, opt ...Option) (v1.Image, error) { - return LoadTag(path, "") + return LoadTag(path, "", opt...) } // LoadTag reads a tag from the tarball at path as a v1.Image. diff --git a/pkg/legacy/tarball/write.go b/pkg/legacy/tarball/write.go index e3f173cbc..627bfbfdb 100644 --- a/pkg/legacy/tarball/write.go +++ b/pkg/legacy/tarball/write.go @@ -313,10 +313,7 @@ func MultiWrite(refToImage map[name.Reference]v1.Image, w io.Writer) error { if err != nil { return err } - if err := writeTarEntry(tf, "repositories", bytes.NewReader(reposBytes), int64(len(reposBytes))); err != nil { - return err - } - return nil + return writeTarEntry(tf, "repositories", bytes.NewReader(reposBytes), int64(len(reposBytes))) } func dedupRefToImage(refToImage map[name.Reference]v1.Image) ([]v1.Image, map[v1.Image][]string) { diff --git a/pkg/v1/daemon/image_test.go b/pkg/v1/daemon/image_test.go index 68adf30b4..74b6f4029 100644 --- a/pkg/v1/daemon/image_test.go +++ b/pkg/v1/daemon/image_test.go @@ -49,7 +49,7 @@ type MockClient struct { saveBody io.ReadCloser } -func (m *MockClient) NegotiateAPIVersion(ctx context.Context) { +func (m *MockClient) NegotiateAPIVersion(_ context.Context) { m.negotiated = true } diff --git a/pkg/v1/daemon/write_test.go b/pkg/v1/daemon/write_test.go index 0e5495cdb..85e3f8ce7 100644 --- a/pkg/v1/daemon/write_test.go +++ b/pkg/v1/daemon/write_test.go @@ -33,7 +33,7 @@ type errReader struct { err error } -func (r *errReader) Read(p []byte) (int, error) { +func (r *errReader) Read(_ []byte) (int, error) { return 0, r.err } @@ -51,7 +51,7 @@ func (m *MockClient) ImageLoad(ctx context.Context, r io.Reader, _ bool) (types. }, m.loadErr } -func (m *MockClient) ImageTag(ctx context.Context, source, target string) error { +func (m *MockClient) ImageTag(ctx context.Context, _, _ string) error { if !m.negotiated { return errors.New("you forgot to call NegotiateAPIVersion before calling ImageTag") } diff --git a/pkg/v1/google/list_test.go b/pkg/v1/google/list_test.go index 5718526a4..91c5cbb04 100644 --- a/pkg/v1/google/list_test.go +++ b/pkg/v1/google/list_test.go @@ -169,7 +169,7 @@ type recorder struct { Errs []error } -func (r *recorder) walk(repo name.Repository, tags *Tags, err error) error { +func (r *recorder) walk(_ name.Repository, tags *Tags, err error) error { r.Tags = append(r.Tags, tags) r.Errs = append(r.Errs, err) diff --git a/pkg/v1/remote/transport/error_test.go b/pkg/v1/remote/transport/error_test.go index e42ce3adc..679b6e1a8 100644 --- a/pkg/v1/remote/transport/error_test.go +++ b/pkg/v1/remote/transport/error_test.go @@ -227,7 +227,7 @@ type errReadCloser struct { err error } -func (e *errReadCloser) Read(p []byte) (int, error) { +func (e *errReadCloser) Read(_ []byte) (int, error) { return 0, e.err } diff --git a/pkg/v1/remote/transport/retry_test.go b/pkg/v1/remote/transport/retry_test.go index ded0ce093..dc65f0836 100644 --- a/pkg/v1/remote/transport/retry_test.go +++ b/pkg/v1/remote/transport/retry_test.go @@ -33,7 +33,7 @@ type mockTransport struct { count int } -func (t *mockTransport) RoundTrip(in *http.Request) (out *http.Response, err error) { +func (t *mockTransport) RoundTrip(_ *http.Request) (out *http.Response, err error) { defer func() { t.count++ }() if t.count < len(t.resps) { out = t.resps[t.count] diff --git a/pkg/v1/remote/write.go b/pkg/v1/remote/write.go index 65d4cc9b9..f4369e2a0 100644 --- a/pkg/v1/remote/write.go +++ b/pkg/v1/remote/write.go @@ -531,10 +531,7 @@ func (w *writer) commitSubjectReferrers(ctx context.Context, sub name.Digest, ad return im.Manifests[i].Digest.String() < im.Manifests[j].Digest.String() }) logs.Progress.Printf("updating fallback tag %s with new referrer", t.Identifier()) - if err := w.commitManifest(ctx, fallbackTaggable{im}, t); err != nil { - return err - } - return nil + return w.commitManifest(ctx, fallbackTaggable{im}, t) } type fallbackTaggable struct { diff --git a/pkg/v1/stream/layer_test.go b/pkg/v1/stream/layer_test.go index e65452b7a..87307b030 100644 --- a/pkg/v1/stream/layer_test.go +++ b/pkg/v1/stream/layer_test.go @@ -157,10 +157,7 @@ func TestStreamableLayerFromTarball(t *testing.T) { return err } } - if err := tw.Close(); err != nil { - return err - } - return nil + return tw.Close() }()) }() diff --git a/pkg/v1/tarball/image.go b/pkg/v1/tarball/image.go index 1f977e16a..c984f3c8f 100644 --- a/pkg/v1/tarball/image.go +++ b/pkg/v1/tarball/image.go @@ -223,9 +223,9 @@ func extractFileFromTar(opener Opener, filePath string) (io.ReadCloser, error) { if err != nil { return nil, err } - close := true + needClose := true defer func() { - if close { + if needClose { f.Close() } }() @@ -244,7 +244,7 @@ func extractFileFromTar(opener Opener, filePath string) (io.ReadCloser, error) { currentDir := filepath.Dir(filePath) return extractFileFromTar(opener, path.Join(currentDir, path.Clean(hdr.Linkname))) } - close = false + needClose = false return tarFile{ Reader: tf, Closer: f,