-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Final vet fixes; enabling vet checks in verify scripts. #24143
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat | |
inputs := sets.NewString(arguments.InputDirs...) | ||
packages := generator.Packages{} | ||
header := append([]byte( | ||
` | ||
// +build !ignore_autogenerated | ||
`// +build !ignore_autogenerated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would re-run the deep copy generator if you do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The newline at the beginning doesn't actually make a difference in output. Same with the conversion one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm.. I would have imagined at least a textual difference. But if there is none, OK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The autogenerated stuff is run through gofmt. |
||
|
||
`), boilerplate...) | ||
header = append(header, []byte( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,10 +132,12 @@ type importRuleFile struct{} | |
|
||
func (importRuleFile) AssembleFile(f *generator.File, path string) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lavalamp Can this whole function just go away? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it implements an interface. |
||
return nil | ||
} | ||
|
||
// TODO: make a flag to enable this, or expose this information in some other way. | ||
func (importRuleFile) listEntireImportTree(f *generator.File, path string) error { | ||
// If the file exists, populate its current imports. This is mostly to help | ||
// humans figure out what they need to fix. | ||
// TODO: add a command line flag to enable this? Or require that it always stay up-to-date? | ||
if _, err := os.Stat(path); err != nil { | ||
// Ignore packages which haven't opted in by adding an .import-restrictions file. | ||
return nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ func (p *Pod) GetUID() string { | |
|
||
// implements Deadlined | ||
func (dp *Pod) Deadline() (time.Time, bool) { | ||
if dp.Deadline != nil { | ||
if dp.deadline != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow. What was the vet error that caught this one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, bad news. "comparison of function Deadline != nil is always true" |
||
return *(dp.deadline), true | ||
} | ||
return time.Time{}, false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,8 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) { | |
} | ||
errors = expvalidation.ValidateDaemonSet(t) | ||
default: | ||
return field.ErrorList{field.InternalError(field.NewPath(""), fmt.Errorf("no validation defined for %#v", obj))} | ||
errors = field.ErrorList{} | ||
errors = append(errors, field.InternalError(field.NewPath(""), fmt.Errorf("no validation defined for %#v", obj))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? Didn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I did expect the addition of godep to fix this and the one in cmd_test.go, but it still complained. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I run go vet in this directory, I get no errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any update on this? I don't see this vet issue from my client. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, you're right, no repro now |
||
} | ||
return errors | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2016 The Kubernetes Authors All rights reserved. | ||
# | ||
# 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 | ||
|
||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. | ||
source "${KUBE_ROOT}/hack/lib/init.sh" | ||
|
||
cd "${KUBE_ROOT}" | ||
|
||
# Use eval to preserve embedded quoted strings. | ||
eval "goflags=(${KUBE_GOFLAGS:-})" | ||
|
||
# Filter out arguments that start with "-" and move them to goflags. | ||
targets=() | ||
for arg; do | ||
if [[ "${arg}" == -* ]]; then | ||
goflags+=("${arg}") | ||
else | ||
targets+=("${arg}") | ||
fi | ||
done | ||
|
||
if [[ ${#targets[@]} -eq 0 ]]; then | ||
# Do not run on third_party directories. | ||
targets=$(go list ./... | grep -v "third_party") | ||
fi | ||
|
||
# Do this in parallel; results in 5-10x speedup. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It also launches a lot of processes. What is the runtime? And is the speed up worth it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Locally - from ~71s to ~14s. |
||
pids="" | ||
for i in $targets | ||
do | ||
( | ||
# Run go vet using goflags for each target specified. | ||
# | ||
# Remove any lines go vet or godep outputs with the exit status. | ||
# Remove any lines godep outputs about the vendor experiment. | ||
# | ||
# If go vet fails (produces output), grep will succeed, but if go vet | ||
# succeeds (produces no output) grep will fail. Then we just use | ||
# PIPESTATUS[0] which is go's exit code. | ||
# | ||
# The intended result is that each incantation of this line returns | ||
# either 0 (pass) or 1 (fail). | ||
godep go vet "${goflags[@]:+${goflags[@]}}" "$i" 2>&1 \ | ||
| grep -v -E "exit status|GO15VENDOREXPERIMENT=" \ | ||
|| fail=${PIPESTATUS[0]} | ||
exit $fail | ||
) & | ||
pids+=" $!" | ||
done | ||
|
||
# Count and return the number of failed files (non-zero is a failed vet run). | ||
failedfiles=0 | ||
for p in $pids; do | ||
wait $p || let "failedfiles+=1" | ||
done | ||
|
||
# hardcode a healthy exit until all vet errors can be fixed | ||
#exit $failedfiles | ||
exit 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't keep up with the handful of vet errors that are added each day. Let me get this PR in, then do one more clean up round. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea that sounds fair. |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also re-run the conversion generator.