Skip to content

Commit

Permalink
chose: update go module dependencies (#829)
Browse files Browse the repository at this point in the history
* chose: update go module dependencies

* bump to go1.20

* bump golangci-lint

seeing error

```
Installing golangci-lint
golangci/golangci-lint info checking GitHub for tag 'v1.44.0'
golangci/golangci-lint info found version: 1.44.0 for v1.44.0/linux/amd64
golangci/golangci-lint info installed /home/runner/go/bin/golangci-lint
panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt

goroutine 1 [running]:
github.com/go-critic/go-critic/checkers.init.22()
	github.com/go-critic/[email protected]/checkers/embedded_rules.go:46 +0x4b4
```

* fix some linting

* some linter updates
  • Loading branch information
ahmetb authored Jul 13, 2023
1 parent 22f508a commit ac28333
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 671 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
goVer: [1.17]
steps:

- name: Set up Go ${{ matrix.goVer }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.goVer }}
go-version: '1.20'
id: go

- name: Check out code into the Go module directory
Expand Down
10 changes: 6 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ linters-settings:
errcheck:
check-type-assertions: false
check-blank: false
staticcheck:
checks:
- all
- "-SA1019" # allow usage of global rand.Seed


# options for analysis running
run:
Expand All @@ -38,9 +43,7 @@ run:
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gci
- gocritic
- gofmt
- goimports
Expand All @@ -51,8 +54,7 @@ linters:
- prealloc
- revive
- staticcheck
- structcheck
- stylecheck
- unconvert
- unparam
- varcheck
- unused
12 changes: 6 additions & 6 deletions cmd/krew/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func printPluginInfo(out io.Writer, indexName string, plugin index.Plugin) {
// indent converts strings to an indented format ready for printing.
// Example:
//
// \
// | This plugin is great, use it with great care.
// | Also, plugin will require the following programs to run:
// | * jq
// | * base64
// /
// \
// | This plugin is great, use it with great care.
// | Also, plugin will require the following programs to run:
// | * jq
// | * base64
// /
func indent(s string) string {
out := "\\\n"
s = strings.TrimRightFunc(s, unicode.IsSpace)
Expand Down
2 changes: 1 addition & 1 deletion cmd/krew/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func init() {
"{{.CommandPath}}", "kubectl {{.CommandPath}}").Replace(rootCmd.UsageTemplate()))
}

func preRun(cmd *cobra.Command, _ []string) error {
func preRun(_ *cobra.Command, _ []string) error {
// check must be done before ensureDirs, to detect krew's self-installation
if !internal.IsBinDirInPATH(paths) {
internal.PrintWarning(os.Stderr, internal.SetupInstructions()+"\n\n")
Expand Down
38 changes: 20 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
module sigs.k8s.io/krew

go 1.17
go 1.20

require (
github.com/fatih/color v1.12.0
github.com/google/go-cmp v0.5.6
github.com/mattn/go-isatty v0.0.13
github.com/fatih/color v1.15.0
github.com/google/go-cmp v0.5.9
github.com/mattn/go-isatty v0.0.19
github.com/pkg/errors v0.9.1
github.com/sahilm/fuzzy v0.1.0
github.com/spf13/cobra v1.2.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
k8s.io/apimachinery v0.21.2
k8s.io/apimachinery v0.27.3
k8s.io/client-go v11.0.0+incompatible
k8s.io/klog/v2 v2.8.0
sigs.k8s.io/yaml v1.2.0
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
)
679 changes: 48 additions & 631 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hack/run-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gopath="$(go env GOPATH)"
if ! [[ -x "$gopath/bin/golangci-lint" ]]; then
echo >&2 'Installing golangci-lint'
curl --silent --fail --location \
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$gopath/bin" v1.44.0
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$gopath/bin" v1.53.3
fi

# configured by .golangci.yml
Expand Down
2 changes: 1 addition & 1 deletion integration_test/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func augmentPATH(t *testing.T, v string) string {
}

// skipShort is a test helper for skipping tests in -test.short runs.
func skipShort(t *testing.T) {
func skipShort(t *testing.T) { //nolint:gocritic
t.Helper()
if testing.Short() {
t.Skip("skipping integration test")
Expand Down
12 changes: 7 additions & 5 deletions internal/download/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,11 @@ func Test_extractMaliciousArchive(t *testing.T) {
// tarGZArchiveForTesting creates an in-memory zip archive with entries from
// the files map, where keys are the paths and values are the contents.
// For example, to create an empty file `a` and another file `b/c`:
// tarGZArchiveForTesting(map[string]string{
// "a": "",
// "b/c": "nested content",
// })
//
// tarGZArchiveForTesting(map[string]string{
// "a": "",
// "b/c": "nested content",
// })
func tarGZArchiveForTesting(files map[string]string) (*bytes.Reader, error) {
archiveBuffer := &bytes.Buffer{}
gzArchiveBuffer := gzip.NewWriter(archiveBuffer)
Expand Down Expand Up @@ -624,7 +625,8 @@ func tarGZArchiveForTesting(files map[string]string) (*bytes.Reader, error) {
// entries with empty content just create a directory. The zip spec requires that
// parent directories are explicitly listed in the archive, so this must be done
// for nested entries. For example, to create a file at `a/b/c`, you must pass:
// map[string]string{"a": "", "a/b": "", "a/b/c": "nested content"}
//
// map[string]string{"a": "", "a/b": "", "a/b/c": "nested content"}
func zipArchiveReaderForTesting(files map[string]string) (*bytes.Reader, error) {
archiveBuffer := &bytes.Buffer{}
zw := zip.NewWriter(archiveBuffer)
Expand Down

0 comments on commit ac28333

Please sign in to comment.