Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various lints #1507

Merged
merged 9 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/krane/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/google/go-containerregistry/cmd/krane

go 1.17
go 1.18

replace github.com/google/go-containerregistry => ../../

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/google/go-containerregistry

go 1.17
go 1.18

require (
github.com/containerd/stargz-snapshotter/estargz v0.12.1
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func interactive(in io.Reader, out io.Writer) bool {
return interactiveFile(in) && interactiveFile(out)
}

func interactiveFile(i interface{}) bool {
func interactiveFile(i any) bool {
f, ok := i.(*os.File)
if !ok {
return false
Expand Down
6 changes: 4 additions & 2 deletions internal/compression/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package compression abstracts over gzip and zstd.
package compression

import (
Expand All @@ -24,6 +25,7 @@ import (
"github.com/google/go-containerregistry/pkg/compression"
)

// Opener represents e.g. opening a file.
type Opener = func() (io.ReadCloser, error)

// GetCompression detects whether an Opener is compressed and which algorithm is used.
Expand Down Expand Up @@ -76,9 +78,9 @@ type PeekReader interface {
func intoPeekReader(r io.Reader) PeekReader {
if p, ok := r.(PeekReader); ok {
return p
} else {
return bufio.NewReader(r)
}

return bufio.NewReader(r)
}

// CheckHeader checks whether the first bytes from a PeekReader match an expected header
Expand Down
4 changes: 3 additions & 1 deletion internal/compression/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func testPeekCompression(t *testing.T,

compressed := compress(io.NopCloser(contentBuf))
compressionDetected, pr, err := PeekCompression(compressed)

if err != nil {
t.Error("PeekCompression() =", err)
}
Expand All @@ -47,6 +46,9 @@ func testPeekCompression(t *testing.T,
}

decompressed, err := decompress(withCloser(pr, compressed))
if err != nil {
t.Fatal(err)
}

b, err := io.ReadAll(decompressed)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/gzip/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/google/go-containerregistry/internal/and"
)

// MagicHeader is the start of gzip files.
var MagicHeader = []byte{'\x1f', '\x8b'}

// ReadCloser reads uncompressed input data from the io.ReadCloser and
Expand Down
2 changes: 2 additions & 0 deletions internal/zstd/zstd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package zstd provides helper functions for interacting with zstd streams.
package zstd

import (
Expand All @@ -23,6 +24,7 @@ import (
"github.com/klauspost/compress/zstd"
)

// MagicHeader is the start of zstd files.
var MagicHeader = []byte{'\x28', '\xb5', '\x2f', '\xfd'}

// ReadCloser reads uncompressed input data from the io.ReadCloser and
Expand Down
2 changes: 1 addition & 1 deletion pkg/authn/k8schain/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/google/go-containerregistry/pkg/authn/k8schain

go 1.17
go 1.18

replace (
github.com/google/go-containerregistry => ../../../
Expand Down
2 changes: 1 addition & 1 deletion pkg/authn/kubernetes/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/google/go-containerregistry/pkg/authn/kubernetes

go 1.17
go 1.18

replace github.com/google/go-containerregistry => ../../../

Expand Down
2 changes: 1 addition & 1 deletion pkg/authn/kubernetes/keychain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func testResolve(t *testing.T, kc authn.Keychain, target authn.Resource, expecte
}
}

func toJSON(t *testing.T, obj interface{}) []byte {
func toJSON(t *testing.T, obj any) []byte {
t.Helper()

bites, err := json.Marshal(obj)
Expand Down
2 changes: 1 addition & 1 deletion pkg/crane/crane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func TestBadInputs(t *testing.T) {

// e drops the first parameter so we can use the result of a function
// that returns two values as an expression above. This is a bit of a go quirk.
e := func(_ interface{}, err error) error {
e := func(_ any, err error) error {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/name/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (e *ErrBadName) Is(target error) bool {
}

// newErrBadName returns a ErrBadName which returns the given formatted string from Error().
func newErrBadName(fmtStr string, args ...interface{}) *ErrBadName {
func newErrBadName(fmtStr string, args ...any) *ErrBadName {
return &ErrBadName{fmt.Sprintf(fmtStr, args...)}
}

Expand Down
34 changes: 17 additions & 17 deletions pkg/v1/fake/image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions pkg/v1/fake/index.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/v1/mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (a arbitraryRawManifest) RawManifest() ([]byte, error) {
if err != nil {
return nil, err
}
var m map[string]interface{}
var m map[string]any
if err := json.Unmarshal(b, &m); err != nil {
return nil, err
}
Expand Down
Loading