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

Update GO v1.21 #476

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
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
4 changes: 2 additions & 2 deletions .github/workflows/cli-coexistence_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v1

- name: Set up Go 1.x
- name: Set up Go 1.21
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
id: go

- name: go cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cli_core_e2e_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Set up Go 1.x
- name: Set up Go 1.21
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
id: go

- name: go cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cli_core_unit_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Set up Go 1.x
- name: Set up Go 1.21
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
id: go

- name: go cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
echo "free space after cleanup:"
df -h

- name: Set up Go 1.x
- name: Set up Go 1.21
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
100 changes: 73 additions & 27 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sounds like sounding that is rather cumbersome to maintain. Can you summarize when a pattern needs to be added to the allow list, because it does not seem to cover all of go.mod

- 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
Comment on lines -78 to -84
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these removals intentional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question. If they are, in the future it would be good to mention in the PR description or a comment in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes these are deprecated in new golangci-lint version. Updated the PR description


# 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.
- EXC0011
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the comment as it is.

Suggested change
- EXC0011
- EXC0011 # disable excluding of issues about missing package comments from stylecheck

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
var wg sync.WaitGroup
plugins := make(chan cli.Plugin, len(files))
fatalErrors := make(chan helpers.ErrInfo, len(files))
Expand Down
1 change: 1 addition & 0 deletions cmd/plugin/builder/command/publish/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func convertVersionToStringArray(arrOsArchInfo []osArch) []string {
return oa
}

//nolint:unparam
func createDummyArtifactDir(directoryBasePath, pluginName, recommendedVersion, description string, versions []string) {
var err error

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, "")
}
}
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -41,7 +41,7 @@ require (
github.com/vmware-tanzu/carvel-ytt v0.40.0
github.com/vmware-tanzu/tanzu-cli/test/e2e/framework v0.0.0-00010101000000-000000000000
github.com/vmware-tanzu/tanzu-framework/capabilities/client v0.0.0-20230523145612-1c6fbba34686
github.com/vmware-tanzu/tanzu-plugin-runtime v1.0.0
github.com/vmware-tanzu/tanzu-plugin-runtime v1.0.1
go.pinniped.dev v0.20.0
golang.org/x/mod v0.10.0
golang.org/x/oauth2 v0.8.0
Expand Down
Loading