Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v6
- uses: golangci/golangci-lint-action@v7
test-unit:
strategy:
matrix:
Expand Down
67 changes: 8 additions & 59 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,12 @@
# https://golangci-lint.run/usage/configuration/
run:
timeout: 5m # 1m default times out on github-action runners
version: "2"

linters:
disable-all: true
enable:
# - bodyclose
# - dogsled
# - dupl
- errcheck
- errchkjson
- errorlint
# - funlen
# - gocognit
- goconst
# - gocritic
# - gocyclo
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- makezero
# - misspell
# - musttag
- nakedret
- noctx
- nolintlint
- reassign
# - revive
- staticcheck
# - stylecheck
- typecheck
- unconvert
# - unparam
- unused
# - whitespace

linters-settings:
gosec:
excludes:
- G115 #Potential integer overflow when converting between integer types
# misspell:
# locale: US
nolintlint:
allow-unused: true # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
default: standard

issues:
exclude-dirs:
- test/
- ".*fakes.*"
- ".*mocks.*"
- integration/
exclude-files:
- ".*_test\\.go"
settings:
errcheck:
check-blank: true # assignment to blank identifier: `_ := someFunc()`.

output:
# Sort results by: filepath, line and column.
sort-results: true
formatters:
enable:
- goimports
8 changes: 4 additions & 4 deletions acceptance/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Config struct {
func NewConfig(fs boshsys.FileSystem) (*Config, error) {
path := os.Getenv("BOSH_INIT_CONFIG_PATH")
if path == "" {
return &Config{}, errors.New("Must provide config file via BOSH_INIT_CONFIG_PATH environment variable")
return &Config{}, errors.New("Must provide config file via BOSH_INIT_CONFIG_PATH environment variable") //nolint:staticcheck
}

configContents, err := fs.ReadFile(path)
Expand All @@ -36,15 +36,15 @@ func NewConfig(fs boshsys.FileSystem) (*Config, error) {

func (c *Config) Validate() error {
if c.StemcellPath == "" {
return errors.New("Must provide 'stemcell_path' in config")
return errors.New("Must provide 'stemcell_path' in config") //nolint:staticcheck
}

if c.CPIReleasePath == "" {
return errors.New("Must provide 'cpi_release_path' in config")
return errors.New("Must provide 'cpi_release_path' in config") //nolint:staticcheck
}

if c.DummyCompiledReleasePath == "" {
return errors.New("Must provide 'dummy_compiled_release_path' in config")
return errors.New("Must provide 'dummy_compiled_release_path' in config") //nolint:staticcheck
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion acceptance/instance_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s *instanceSSH) setupSSH() (boshsys.File, error) {
success := false
defer func() {
if !success {
_ = s.fileSystem.RemoveAll(sshConfigFile.Name())
_ = s.fileSystem.RemoveAll(sshConfigFile.Name()) //nolint:errcheck
}
}()

Expand Down
6 changes: 3 additions & 3 deletions acceptance/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var _ = Describe("bosh", func() {
}

var deploy = func(manifestFile string, args ...string) string {
fmt.Fprintf(GinkgoWriter, "\n--- DEPLOY ---\n")
fmt.Fprintf(GinkgoWriter, "\n--- DEPLOY ---\n") //nolint:errcheck

stdout := &bytes.Buffer{}
multiWriter := io.MultiWriter(stdout, GinkgoWriter)
Expand All @@ -126,7 +126,7 @@ var _ = Describe("bosh", func() {
}

var deleteDeployment = func(manifest string, extraDeployArgs ...string) string {
fmt.Fprintf(GinkgoWriter, "\n--- DELETE DEPLOYMENT ---\n")
fmt.Fprintf(GinkgoWriter, "\n--- DELETE DEPLOYMENT ---\n") //nolint:errcheck

stdout := &bytes.Buffer{}
multiWriter := io.MultiWriter(stdout, GinkgoWriter)
Expand Down Expand Up @@ -349,7 +349,7 @@ var _ = Describe("bosh", func() {

It("fails pinging the agent", func() {
By("deploying with a bogus CA cert")
fmt.Fprintf(GinkgoWriter, "\n--- DEPLOY ---\n")
fmt.Fprintf(GinkgoWriter, "\n--- DEPLOY ---\n") //nolint:errcheck

stdoutBuffer := &bytes.Buffer{}
multiWriter := io.MultiWriter(stdoutBuffer, GinkgoWriter)
Expand Down
2 changes: 1 addition & 1 deletion acceptance/test_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (e testEnvironment) Path(name string) string {

func (e testEnvironment) Copy(destName, srcPath string) error {
if srcPath == "" {
return fmt.Errorf("Cannot use an empty source file path '' for destination file '%s'", destName)
return fmt.Errorf("Cannot use an empty source file path '' for destination file '%s'", destName) //nolint:staticcheck
}

_, _, exitCode, err := e.cmdRunner.RunCommand(
Expand Down
2 changes: 1 addition & 1 deletion bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export PATH=${go_bin_path}:${PATH}

golangci-lint version

linted_os_list=(linux)
linted_os_list=(linux darwin)

for os in "${linted_os_list[@]}"; do
echo "lint-ing with GOOS=${os}..."
Expand Down
4 changes: 2 additions & 2 deletions cloud/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ func (e cpiError) OkToRetry() bool {
}

func mapsToNotImplementedError(method string, cmdError CmdError) bool {
matched, _ := regexp.MatchString("^Invalid Method:", cmdError.Message)
matched, _ := regexp.MatchString("^Invalid Method:", cmdError.Message) //nolint:errcheck

if cmdError.Type == "Bosh::Clouds::CloudError" && matched {
return true
}

matched, _ = regexp.MatchString("^Method is not known, got", cmdError.Message)
matched, _ = regexp.MatchString("^Method is not known, got", cmdError.Message) //nolint:errcheck

if cmdError.Type == "InvalidCall" && matched {
return true
Expand Down
4 changes: 2 additions & 2 deletions cmd/add_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-utils/system"

. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshreldir "github.com/cloudfoundry/bosh-cli/v7/releasedir"
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
)
Expand All @@ -27,7 +27,7 @@ func (c AddBlobCmd) Run(opts AddBlobOpts) error {
return bosherr.WrapErrorf(err, "Opening blob")
}

defer file.Close()
defer file.Close() //nolint:errcheck

blob, err := c.blobsDir.TrackBlob(opts.Args.BlobsPath, file)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/alias_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
cmdconf "github.com/cloudfoundry/bosh-cli/v7/cmd/config"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/attach_disk.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cancel_task.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cancel_tasks.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/clean_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"strconv"

. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/v7/ui/table"
Expand Down
4 changes: 2 additions & 2 deletions cmd/cloud_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"

. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/v7/ui/table"
Expand Down Expand Up @@ -77,7 +77,7 @@ func (c CloudCheckCmd) Run(opts CloudCheckOpts) error {
return c.deployment.ResolveProblems(answers, nil)
}

func (_ CloudCheckCmd) applyResolutions(resolutionsToApply []string, probs []boshdir.Problem) ([]boshdir.ProblemAnswer, error) {
func (_ CloudCheckCmd) applyResolutions(resolutionsToApply []string, probs []boshdir.Problem) ([]boshdir.ProblemAnswer, error) { //nolint:staticcheck
var answers []boshdir.ProblemAnswer

for _, prob := range probs {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cloud_config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
)
Expand Down
9 changes: 4 additions & 5 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ import (
"github.com/cppforlife/go-patch/patch"

cmdconf "github.com/cloudfoundry/bosh-cli/v7/cmd/config"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
"github.com/cloudfoundry/bosh-cli/v7/crypto"
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
boshtpl "github.com/cloudfoundry/bosh-cli/v7/director/template"
"github.com/cloudfoundry/bosh-cli/v7/pcap"
boshrel "github.com/cloudfoundry/bosh-cli/v7/release"
boshreldir "github.com/cloudfoundry/bosh-cli/v7/releasedir"
boshssh "github.com/cloudfoundry/bosh-cli/v7/ssh"
bistemcell "github.com/cloudfoundry/bosh-cli/v7/stemcell"
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/v7/ui/table"
boshuit "github.com/cloudfoundry/bosh-cli/v7/ui/task"

boshcrypto "github.com/cloudfoundry/bosh-utils/crypto"
boshfu "github.com/cloudfoundry/bosh-utils/fileutil"

. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
"github.com/cloudfoundry/bosh-cli/v7/pcap"
boshtbl "github.com/cloudfoundry/bosh-cli/v7/ui/table"
)

type Cmd struct {
Expand Down Expand Up @@ -503,7 +502,7 @@ func (c Cmd) Execute() (cmdErr error) {
return NewVariablesCmd(deps.UI, c.deployment()).Run(*opts)

default:
return fmt.Errorf("Unhandled command: %#v", c.Opts)
return fmt.Errorf("Unhandled command: %#v", c.Opts) //nolint:staticcheck
}
}
func (c Cmd) configureUI() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/completion/blind_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package completion
import (
"fmt"

. "github.com/cloudfoundry/bosh-cli/v7/ui/table"
"github.com/cloudfoundry/bosh-cli/v7/ui/table"
)

type BlindUI struct{}
Expand All @@ -26,10 +26,10 @@ func (ui *BlindUI) PrintBlock(_ []byte) {
func (ui *BlindUI) PrintErrorBlock(_ string) {
}

func (ui *BlindUI) PrintTable(_ Table) {
func (ui *BlindUI) PrintTable(_ table.Table) {
}

func (ui *BlindUI) PrintTableFiltered(_ Table, _ []Header) {
func (ui *BlindUI) PrintTableFiltered(_ table.Table, _ []table.Header) {
}

func (ui *BlindUI) AskForText(_ string) (string, error) {
Expand Down
6 changes: 3 additions & 3 deletions cmd/completion/complete_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *CompleteCache) configure(cmdContext *CmdContext, group string) {
}

func (c *CompleteCache) normalizeString(str string) string {
matched, _ := regexp.MatchString("^[a-zA-Z0-9_-]+$", str)
matched, _ := regexp.MatchString("^[a-zA-Z0-9_-]+$", str) //nolint:errcheck
if matched {
hash := md5.Sum([]byte(str)) //nolint:gosec
return hex.EncodeToString(hash[:])
Expand All @@ -68,7 +68,7 @@ func (c *CompleteCache) normalizeString(str string) string {
}
}
func (c *CompleteCache) prepareCacheDir(cmdContext *CmdContext) string {
basePath, _ := c.normalizeDirPath(cmdContext.ConfigPath)
basePath, _ := c.normalizeDirPath(cmdContext.ConfigPath) //nolint:errcheck
basePath = filepath.Join(filepath.Dir(basePath), "completion-cache")
c.logger.Debug(c.logTag, "cache directory '%s', config directory '%s'", basePath, cmdContext.ConfigPath)
if err := c.ensureDirExists(basePath); err != nil {
Expand Down Expand Up @@ -141,7 +141,7 @@ func (c *CompleteCache) GetValues() (values []string, valid bool, err error) {
}
valid = time.Since(item.Timestamp) < c.expirationPeriod
if !valid {
_ = c.store.Erase(c.cacheKey)
_ = c.store.Erase(c.cacheKey) //nolint:errcheck
}
return item.Values, valid, nil
}
2 changes: 1 addition & 1 deletion cmd/completion/director_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (c *DirectorQuery) listDirectorApiEndpoints(prefix string) ([]string, error

func (c *DirectorQuery) readFromCache(group string) (cache *CompleteCache, values []string, valid bool) {
cache = NewCompleteCache(c.logger, c.cmdContext, group)
if values, valid, _ = cache.GetValues(); valid {
if values, valid, _ = cache.GetValues(); valid { //nolint:errcheck
c.logger.Debug(c.logTag, "'%' read from cache %s", group, cache)
return cache, values, valid
} else {
Expand Down
2 changes: 1 addition & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"

. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/fs_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ var _ = Describe("FSConfig", func() {
config := readConfig()
err := config.Save()
Expect(err).ToNot(HaveOccurred())
fileInfo, _ := fs.Stat("/dir/sub-dir/config")
fileInfo, _ := fs.Stat("/dir/sub-dir/config") //nolint:errcheck
Expect(fileInfo.Mode()).To(Equal(os.FileMode(0600)))
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/configs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts" //nolint:staticcheck
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
boshui "github.com/cloudfoundry/bosh-cli/v7/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/v7/ui/table"
Expand Down
Loading
Loading