Use golangci-lint.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
c7b48c09d7
commit
9bf53555a0
11
Makefile
11
Makefile
@ -45,7 +45,7 @@ version: ## print current cri plugin release version
|
||||
|
||||
lint:
|
||||
@echo "$(WHALE) $@"
|
||||
@./hack/verify-lint.sh
|
||||
golangci-lint run --skip-files .*_test.go
|
||||
|
||||
gofmt:
|
||||
@echo "$(WHALE) $@"
|
||||
@ -159,19 +159,18 @@ else
|
||||
git-validation -v -run DCO,short-subject -range $(EPOCH_TEST_COMMIT)..HEAD
|
||||
endif
|
||||
|
||||
.PHONY: install.tools .install.gitvalidation .install.gometalinter .install.vndr
|
||||
.PHONY: install.tools .install.gitvalidation .install.golangci-lint .install.vndr
|
||||
|
||||
install.tools: .install.gitvalidation .install.gometalinter .install.vndr ## install tools used by verify
|
||||
install.tools: .install.gitvalidation .install.golangci-lint .install.vndr ## install tools used by verify
|
||||
@echo "$(WHALE) $@"
|
||||
|
||||
.install.gitvalidation:
|
||||
@echo "$(WHALE) $@"
|
||||
$(GO) get -u github.com/vbatts/git-validation
|
||||
|
||||
.install.gometalinter:
|
||||
.install.golangci-lint:
|
||||
@echo "$(WHALE) $@"
|
||||
$(GO) get -u github.com/alecthomas/gometalinter
|
||||
gometalinter --install
|
||||
$(GO) get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
|
||||
.install.vndr:
|
||||
@echo "$(WHALE) $@"
|
||||
|
@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
for d in $(find . -type d -a \( -iwholename './pkg*' -o -iwholename './cmd*' \) -not -iwholename './pkg/api*'); do
|
||||
echo for directory ${d} ...
|
||||
gometalinter \
|
||||
--exclude='error return value not checked.*(Close|Log|Print|Fprint).*\(errcheck\)$' \
|
||||
--exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \
|
||||
--exclude='duplicate of.*_test.go.*\(dupl\)$' \
|
||||
--exclude='.*/mock_.*\.go:.*\(golint\)$' \
|
||||
--exclude='declaration of "err" shadows declaration.*\(vetshadow\)$' \
|
||||
--exclude='struct of size .* could be .* \(maligned\)$' \
|
||||
--disable=aligncheck \
|
||||
--disable=gotype \
|
||||
--disable=gas \
|
||||
--disable=gosec \
|
||||
--cyclo-over=60 \
|
||||
--dupl-threshold=100 \
|
||||
--tests \
|
||||
--deadline=600s "${d}"
|
||||
done
|
@ -21,6 +21,7 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -350,7 +351,13 @@ func RawRuntimeClient() (runtime.RuntimeServiceClient, error) {
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(dialer))
|
||||
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithContextDialer(
|
||||
func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
return dialer(addr, time.Until(deadline))
|
||||
}
|
||||
return dialer(addr, 0)
|
||||
}))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to connect cri endpoint")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user