Skip to content

Commit

Permalink
Fix a few lint issues (#1684)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr authored May 1, 2023
1 parent 3120ba5 commit 370e8a5
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cmd/crane/cmd/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pkg/authn/keychain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crane/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions pkg/legacy/tarball/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/daemon/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/v1/daemon/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/google/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/remote/transport/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/remote/transport/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions pkg/v1/remote/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions pkg/v1/stream/layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ func TestStreamableLayerFromTarball(t *testing.T) {
return err
}
}
if err := tw.Close(); err != nil {
return err
}
return nil
return tw.Close()
}())
}()

Expand Down
6 changes: 3 additions & 3 deletions pkg/v1/tarball/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}()
Expand All @@ -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,
Expand Down

0 comments on commit 370e8a5

Please sign in to comment.