diff --git a/hack/tools/go.mod b/hack/tools/go.mod index ce9aab4951..8d4a35af60 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -3,9 +3,11 @@ module sigs.k8s.io/kind/hack/tools go 1.12 require ( + github.com/BurntSushi/toml v0.3.1 // indirect github.com/spf13/pflag v1.0.2 // indirect golang.org/x/lint v0.0.0-20180702182130-06c8688daad7 - golang.org/x/tools v0.0.0-20180911133044-677d2ff680c1 // indirect + golang.org/x/tools v0.0.0-20190514230902-921b34c7d07f // indirect + honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a // indirect k8s.io/code-generator v0.0.0-20181116211957-405721ab9678 k8s.io/gengo v0.0.0-20181113154421-fd15ee9cc2f7 // indirect k8s.io/klog v0.1.0 // indirect diff --git a/hack/tools/go.sum b/hack/tools/go.sum index 80a3c940f4..7df30707e8 100644 --- a/hack/tools/go.sum +++ b/hack/tools/go.sum @@ -1,9 +1,20 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7 h1:00BeQWmeaGazuOrq8Q5K5d3/cHaGuFrZzpaHBXfrsUA= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20180911133044-677d2ff680c1 h1:dzEuQYa6+a3gROnSlgly5ERUm4SZKJt+dh+4iSbO+bI= golang.org/x/tools v0.0.0-20180911133044-677d2ff680c1/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190514230902-921b34c7d07f h1:dts7Z0mEJGlDyDVnbbogjfEhUYvrBjvYECNJxwG5IK8= +golang.org/x/tools v0.0.0-20190514230902-921b34c7d07f/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a h1:LJwr7TCTghdatWv40WobzlKXc9c4s8oGa7QKJUtHhWA= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/code-generator v0.0.0-20181116211957-405721ab9678 h1:HymXxD0e1DpTrSSXAj+vsAag/sqvq/mCv4J2OONqM90= k8s.io/code-generator v0.0.0-20181116211957-405721ab9678/go.mod h1:MYiN+ZJZ9HkETbgVZdWw2AsuAi9PZ4V80cwfuf2axe8= k8s.io/gengo v0.0.0-20181113154421-fd15ee9cc2f7 h1:zjNgw2qqBQmKd0S59lGZBQqFxJqUZroVbDphfnVm5do= diff --git a/hack/tools/tools.go b/hack/tools/tools.go index ca57cf85c3..07480a3ca6 100644 --- a/hack/tools/tools.go +++ b/hack/tools/tools.go @@ -9,6 +9,7 @@ package tools import ( // linter(s) _ "golang.org/x/lint" + _ "honnef.co/go/tools/cmd/staticcheck" // kubernetes code generators _ "k8s.io/code-generator/cmd/conversion-gen" diff --git a/hack/verify-all.sh b/hack/verify-all.sh index cb4af91014..7f25893f86 100755 --- a/hack/verify-all.sh +++ b/hack/verify-all.sh @@ -50,6 +50,12 @@ if [[ "${VERIFY_GOVET:-true}" == "true" ]]; then cd "${REPO_ROOT}" fi +if [[ "${VERIFY_STATICCHECK:-true}" == "true" ]]; then + echo "verifying staticcheck ..." + hack/verify-staticcheck.sh || res=1 + cd "${REPO_ROOT}" +fi + if [[ "${VERIFY_GENERATED:-true}" == "true" ]]; then echo "verifying generated ..." hack/verify-generated.sh || res=1 diff --git a/hack/verify-staticcheck.sh b/hack/verify-staticcheck.sh new file mode 100755 index 0000000000..e96796d847 --- /dev/null +++ b/hack/verify-staticcheck.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Copyright 2019 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. + +# CI script to run staticcheck +set -o errexit +set -o nounset +set -o pipefail + +# cd to the repo root +REPO_ROOT=$(git rev-parse --show-toplevel) +cd "${REPO_ROOT}" + +# enable modules and the proxy cache +export GO111MODULE="on" +GOPROXY="${GOPROXY:-https://proxy.golang.org}" +export GOPROXY + +# build staticcheck +BINDIR="${REPO_ROOT}/bin" +# use the tools module +cd "hack/tools" +go build -o "${BINDIR}/staticcheck" honnef.co/go/tools/cmd/staticcheck +# go back to the root +cd "${REPO_ROOT}" + +"${BINDIR}/staticcheck" ./pkg/... ./cmd/... . diff --git a/pkg/cluster/config/fuzzer/fuzzer.go b/pkg/cluster/config/fuzzer/fuzzer.go index 3600d6966a..7fed7c8d27 100644 --- a/pkg/cluster/config/fuzzer/fuzzer.go +++ b/pkg/cluster/config/fuzzer/fuzzer.go @@ -28,6 +28,7 @@ import ( func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ fuzzConfig, + fuzzNode, } }