Skip to content

Commit

Permalink
Update go 1.21 and fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanchajanya committed Sep 22, 2023
1 parent c0e6210 commit db46514
Show file tree
Hide file tree
Showing 41 changed files with 449 additions and 153 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
id: go

- name: Config credentials
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cli-coexistence_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
id: go

- name: go cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cli_core_e2e_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
id: go

- name: go cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cli_core_unit_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
id: go

- name: go cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.21
id: go

- name: Check out code into the Go module directory
Expand Down
98 changes: 72 additions & 26 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
linters-settings:
depguard:
rules:
main:
files:
- $all
- "!$test"
allow:
- $gostd
- github.com/AlecAivazis/survey/v2
- github.com/Masterminds/semver
- github.com/adrg/xdg
- github.com/cppforlife/go-cli-ui
- github.com/fatih/color
- github.com/gobwas/glob
- github.com/golang-jwt/jwt
- github.com/google/gnostic
- github.com/google/go-containerregistry
- github.com/google/uuid
- github.com/gorilla/mux
- github.com/imdario/mergo
- github.com/juju/fslock
- github.com/k14s/kbld
- github.com/lithammer/dedent
- github.com/logrusorgru/aurora
- github.com/novln/docker-parser
- github.com/onsi/ginkgo/v2
- github.com/onsi/gomega
- github.com/otiai10/copy
- github.com/pkg/errors
- github.com/sigstore/cosign/v2
- github.com/sigstore/sigstore
- github.com/spf13/afero
- github.com/spf13/cobra
- github.com/spf13/pflag
- github.com/stretchr/testify
- github.com/tj/assert
- github.com/verybluebot/tarinator-go
- github.com/vmware-tanzu/carvel-imgpkg
- github.com/vmware-tanzu/carvel-ytt
- github.com/vmware-tanzu/tanzu-cli
- github.com/vmware-tanzu/tanzu-cli/test/e2e/framework
- github.com/vmware-tanzu/tanzu-framework/capabilities/client
- github.com/vmware-tanzu/tanzu-plugin-runtime
- go.pinniped.dev
- go.uber.org/multierr
- google.golang.org/grpc
- golang.org/x/oauth2
- golang.org/x/sync/errgroup
- golang.org/x/mod/semver
- gopkg.in/yaml.v2
- gopkg.in/yaml.v3
- k8s.io/api
- k8s.io/apimachinery
- k8s.io/client-go
- modernc.org/sqlite
- sigs.k8s.io/controller-runtime
deny:
- pkg: github.com/sirupsen/logrus
desc: not allowed
dupl:
threshold: 100
funlen:
Expand All @@ -7,7 +66,7 @@ linters-settings:
goheader:
values:
const:
COMPANY: VMware, Inc.
COMPANY: 'VMware, Inc.'
LICENSE: Apache-2.0
regexp:
YEAR: 20\d*-*\d*
Expand Down Expand Up @@ -36,7 +95,6 @@ linters-settings:
local-prefixes: github.com/vmware-tanzu
govet:
check-shadowing: true

misspell:
locale: US
nolintlint:
Expand All @@ -46,11 +104,9 @@ linters-settings:
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
whitespace:
multi-func: true

linters:
disable-all: true
enable:
- deadcode
- depguard
- dogsled
- dupl
Expand All @@ -75,14 +131,10 @@ linters:
- typecheck
- unconvert
- unused
- varcheck
- whitespace
- bodyclose
- noctx
- rowserrcheck
- structcheck
- unparam

# don't enable:
# - asciicheck
# - exhaustive
Expand All @@ -102,49 +154,43 @@ linters:

issues:
exclude:
- 'declaration of "(err|ctx)" shadows declaration at'
- "unnamedResult: consider giving a name to these results"
- "(Expect directory permissions to be 0750 or less|Expect (WriteFile|file) permissions to be 0600 or less)"

- declaration of "(err|ctx)" shadows declaration at
- 'unnamedResult: consider giving a name to these results'
- >-
(Expect directory permissions to be 0750 or less|Expect (WriteFile|file)
permissions to be 0600 or less)
exclude-rules:
- linters:
- gosec
text: 'G602:'
- path: _test\.go
linters:
- dupl
- gocritic
- funlen

# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"

text: 'unnecessaryDefer:'
- linters:
- revive
text: "that stutters"

text: that stutters
- path: zz_.*\.go
linters:
- revive
text: "it will be inferred from"

# Ignore the deprecated function use (staticcheck, SA1019) for the test files
text: it will be inferred from
- path: (.+)_test.go
linters:
- staticcheck
text: "SA1019:"

text: 'SA1019:'
include:
- EXC0011 # disable excluding of issues about missing package comments from stylecheck

# Show all errors for all linters. Setting these to 0 disables limiting error reporting.
max-same-issues: 0
max-issues-per-linter: 0

run:
skip-dirs:
- fakes/
timeout: 15m

# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
Expand Down
2 changes: 1 addition & 1 deletion cmd/plugin/builder/command/cli_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func Compile(compileArgs *PluginCompileArgs) error {
guard := make(chan struct{}, maxConcurrent)

// Mix up IDs so we don't always get the same set.
randSkew := rand.Intn(len(helpers.Identifiers)) // nolint:gosec
randSkew := rand.Intn(len(helpers.Identifiers)) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
var wg sync.WaitGroup
plugins := make(chan cli.Plugin, len(files))
fatalErrors := make(chan helpers.ErrInfo, len(files))
Expand Down
8 changes: 4 additions & 4 deletions cmd/plugin/builder/inventory_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ type inventoryPluginActivateDeactivateFlags struct {
InventoryDBFile string
}

func newInventoryPluginActivateCmd() *cobra.Command { // nolint:dupl
func newInventoryPluginActivateCmd() *cobra.Command { //nolint:dupl
pluginActivateCmd, flags := getActivateDeactivateBaseCmd()
pluginActivateCmd.Use = "activate" // nolint:goconst
pluginActivateCmd.Use = "activate" //nolint:goconst
pluginActivateCmd.Short = "Activate the existing plugin in the inventory database available on the remote repository"
pluginActivateCmd.Example = ""
pluginActivateCmd.RunE = func(cmd *cobra.Command, args []string) error {
Expand All @@ -111,9 +111,9 @@ func newInventoryPluginActivateCmd() *cobra.Command { // nolint:dupl
return pluginActivateCmd
}

func newInventoryPluginDeactivateCmd() *cobra.Command { // nolint:dupl
func newInventoryPluginDeactivateCmd() *cobra.Command { //nolint:dupl
pluginDeactivateCmd, flags := getActivateDeactivateBaseCmd()
pluginDeactivateCmd.Use = "deactivate" // nolint:goconst
pluginDeactivateCmd.Use = "deactivate" //nolint:goconst
pluginDeactivateCmd.Short = "Deactivate the existing plugin in the inventory database available on the remote repository"
pluginDeactivateCmd.Example = ""
pluginDeactivateCmd.RunE = func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/plugin/test/test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
}
}

func test(c *cobra.Command, _ []string) error {
func test(_ *cobra.Command, _ []string) error {
return nil
}

Expand Down
7 changes: 3 additions & 4 deletions cmd/tanzu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ func main() {
// If a plugin exited with an error, we don't want to print its
// exit status as a string, but want to use it as our own exit code.
os.Exit(errStr.ExitCode())
} else {
// We got an error other than a plugin exiting with an error, let's
// print the error message.
log.Fatal(err, "")
}
// We got an error other than a plugin exiting with an error, let's
// print the error message.
log.Fatal(err, "")
}
}
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/vmware-tanzu/tanzu-cli

go 1.19
go 1.21

replace cloud.google.com/go => cloud.google.com/go v0.102.1

Expand Down
Loading

0 comments on commit db46514

Please sign in to comment.