Skip to content

Commit

Permalink
validate: add context to connection error (#1081)
Browse files Browse the repository at this point in the history
* validate: add context to connection error

When src-validate fails to connect to a service, name that service in
the error message.

* Bump golangci-lint

To avoid memory leak / timeout.

Fix up depguard config. Fix a formatting error. Leave one linter error
in place for now, it'll be fixed in a subsequent commit, as it's a bit
more complex.
  • Loading branch information
craigfurman committed May 15, 2024
1 parent 03b18dd commit 849335b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
21 changes: 13 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ linters:

linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages-with-error-message:
- errors: 'Use github.com/sourcegraph/sourcegraph/lib/errors instead'
- github.com/pkg/errors: 'Use github.com/sourcegraph/sourcegraph/lib/errors instead'
- github.com/cockroachdb/errors: 'Use github.com/sourcegraph/sourcegraph/lib/errors instead'
- github.com/hashicorp/go-multierror: 'Use github.com/sourcegraph/sourcegraph/lib/errors instead'
- io/ioutil: 'The ioutil package has been deprecated'
rules:
main:
deny:
- pkg: "errors"
desc: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
- pkg: "github.com/pkg/errors"
desc: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
- pkg: "github.com/cockroachdb/errors"
desc: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
- pkg: "github.com/hashicorp/go-multierror"
desc: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
- pkg: "io/ioutil"
desc: "The ioutil package has been deprecated"
gocritic:
disabled-checks:
- appendAssign # Too many false positives
Expand Down
2 changes: 1 addition & 1 deletion dev/golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null

mkdir -p dev/.bin

version="1.51.2"
version="1.58.1"
suffix="${version}-$(go env GOOS)-$(go env GOARCH)"
target="$PWD/dev/.bin/golangci-lint-${suffix}"
url="https://github.com/golangci/golangci-lint/releases/download/v${version}/golangci-lint-${suffix}.tar.gz"
Expand Down
4 changes: 2 additions & 2 deletions internal/batches/ui/task_exec_tui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestTaskExecTUI_Integration(t *testing.T) {

buf := &ttyBuf{}

true_ := true
true_ := true
out := output.NewOutput(buf, output.OutputOpts{
ForceTTY: &true_,
ForceColor: true,
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestProgressUpdateAfterComplete(t *testing.T) {
now := time.Now()
clock := func() time.Time { return now.UTC().Truncate(time.Millisecond) }

true_ := true
true_ := true
out := output.NewOutput(buf, output.OutputOpts{
ForceTTY: &true_,
ForceColor: true,
Expand Down
2 changes: 1 addition & 1 deletion internal/validate/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func Connections(ctx context.Context, config *Config) ([]validate.Result, error)
Stderr: &stderr,
})
if err != nil {
return nil, err
return nil, errors.Wrapf(err, "connecting to %s", c.src.Name)
}

if stderr.String() != "" {
Expand Down

0 comments on commit 849335b

Please sign in to comment.