Skip to content

Commit

Permalink
lint: fix issues with go 1.18
Browse files Browse the repository at this point in the history
nolint for strings.Title, we only have ASCII strings
and want to capitalize only the first character so no
need to worry about unicode

also adds our own definition for temporary network
error so we can continue to propagate net.Error through
the "temporary" status

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Mar 23, 2022
1 parent a633fa4 commit 7b6ae19
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/dockerfile/instructions/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func errExactlyOneArgument(command string) error {
}

func errNoDestinationArgument(command string) error {
return errors.Errorf("%s requires at least two arguments, but only one was provided. Destination could not be determined.", command)
return errors.Errorf("%s requires at least two arguments, but only one was provided. Destination could not be determined", command)
}

func errBadHeredoc(command string, option string) error {
Expand Down
1 change: 1 addition & 0 deletions hack/dockerfiles/lint.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# syntax=docker/dockerfile-upstream:master

FROM golang:1.18-alpine
ENV GOFLAGS="-buildvcs=false"
RUN apk add --no-cache gcc musl-dev yamllint
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.0
WORKDIR /go/src/github.com/moby/buildkit
Expand Down
2 changes: 1 addition & 1 deletion solver/testutil/cachestorage_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func testWalkIDsByResult(t *testing.T, st solver.CacheKeyStorage) {
func getFunctionName(i interface{}) string {
fullname := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
dot := strings.LastIndex(fullname, ".") + 1
return strings.Title(fullname[dot:])
return strings.Title(fullname[dot:]) //nolint:staticcheck // SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
}

func rootKey(dgst digest.Digest, output solver.Index) digest.Digest {
Expand Down
15 changes: 14 additions & 1 deletion util/resolver/retryhandler/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func retryError(err error) bool {
return true
}
// catches TLS timeout or other network-related temporary errors
if ne, ok := errors.Cause(err).(net.Error); ok && ne.Temporary() {
if ne, ok := errors.Cause(err).(net.Error); ok && (ne.Timeout() || isTemporaryNetworkError(ne)) {
return true
}
// https://github.com/containerd/containerd/pull/4724
Expand All @@ -70,3 +70,16 @@ func retryError(err error) bool {

return false
}

// isTemporaryNetworkError returns false unless the error implements
// a Temporary() bool method such as url.Error and net.Error.
// Otherwise, returns the value of the Temporary() method.
func isTemporaryNetworkError(err error) bool {
t, ok := err.(interface {
Temporary() bool
})
if !ok {
return false
}
return t.Temporary()
}
2 changes: 1 addition & 1 deletion util/testutil/integration/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func Run(t *testing.T, testCases []Test, opt ...TestOpt) {
func getFunctionName(i interface{}) string {
fullname := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
dot := strings.LastIndex(fullname, ".") + 1
return strings.Title(fullname[dot:])
return strings.Title(fullname[dot:]) //nolint:staticcheck // SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
}

var localImageCache map[string]map[string]struct{}
Expand Down

0 comments on commit 7b6ae19

Please sign in to comment.