mirror of https://github.com/k3s-io/k3s
Final vet fixes; enabling vet checks in verify scripts.
parent
f2db7d07a3
commit
a3104ba96c
|
@ -220,7 +220,7 @@ func TestParseRuntimeConfig(t *testing.T) {
|
|||
|
||||
expectedConfig := test.expectedAPIConfig()
|
||||
if err == nil && !reflect.DeepEqual(actualDisablers, expectedConfig) {
|
||||
t.Fatalf("%v: unexpected apiResourceDisablers. Actual: %q\n expected: %q", test.runtimeConfig, actualDisablers, expectedConfig)
|
||||
t.Fatalf("%v: unexpected apiResourceDisablers. Actual: %v\n expected: %v", test.runtimeConfig, actualDisablers, expectedConfig)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
|||
return generator.Packages(packageList)
|
||||
}
|
||||
|
||||
orderer := namer.Orderer{namer.NewPrivateNamer(0)}
|
||||
orderer := namer.Orderer{Namer: namer.NewPrivateNamer(0)}
|
||||
for _, gv := range customArgs.GroupVersions {
|
||||
types := gvToTypes[gv]
|
||||
packageList = append(packageList, packageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, arguments.OutputBase, boilerplate, generatedBy))
|
||||
|
|
|
@ -95,15 +95,15 @@ func main() {
|
|||
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup",
|
||||
}...)
|
||||
arguments.CustomArgs = clientgenargs.Args{
|
||||
[]unversioned.GroupVersion{{Group: "testgroup", Version: ""}},
|
||||
map[unversioned.GroupVersion]string{
|
||||
GroupVersions: []unversioned.GroupVersion{{Group: "testgroup", Version: ""}},
|
||||
GroupVersionToInputPath: map[unversioned.GroupVersion]string{
|
||||
unversioned.GroupVersion{Group: "testgroup", Version: ""}: "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup",
|
||||
},
|
||||
"test_internalclientset",
|
||||
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/",
|
||||
false,
|
||||
false,
|
||||
cmdArgs,
|
||||
ClientsetName: "test_internalclientset",
|
||||
ClientsetOutputPath: "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/",
|
||||
ClientsetOnly: false,
|
||||
FakeClient: false,
|
||||
CmdArgs: cmdArgs,
|
||||
}
|
||||
} else {
|
||||
inputPath, groupVersions, gvToPath, err := parseInputVersions()
|
||||
|
@ -114,13 +114,13 @@ func main() {
|
|||
arguments.InputDirs = append(inputPath, dependencies...)
|
||||
|
||||
arguments.CustomArgs = clientgenargs.Args{
|
||||
groupVersions,
|
||||
gvToPath,
|
||||
*clientsetName,
|
||||
*clientsetPath,
|
||||
*clientsetOnly,
|
||||
*fakeClient,
|
||||
cmdArgs,
|
||||
GroupVersions: groupVersions,
|
||||
GroupVersionToInputPath: gvToPath,
|
||||
ClientsetName: *clientsetName,
|
||||
ClientsetOutputPath: *clientsetPath,
|
||||
ClientsetOnly: *clientsetOnly,
|
||||
FakeClient: *fakeClient,
|
||||
CmdArgs: cmdArgs,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,8 +131,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
|
||||
|
||||
`), boilerplate...)
|
||||
header = append(header, []byte(
|
||||
|
|
|
@ -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
|
||||
|
||||
`), boilerplate...)
|
||||
header = append(header, []byte(
|
||||
|
|
|
@ -184,7 +184,7 @@ func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrder
|
|||
for name, systemNamer := range nameSystems {
|
||||
c.Namers[name] = systemNamer
|
||||
if name == canonicalOrderName {
|
||||
orderer := namer.Orderer{systemNamer}
|
||||
orderer := namer.Orderer{Namer: systemNamer}
|
||||
c.Order = orderer.OrderUniverse(u)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,10 +132,12 @@ type importRuleFile struct{}
|
|||
|
||||
func (importRuleFile) AssembleFile(f *generator.File, path string) error {
|
||||
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
|
||||
|
|
|
@ -38,7 +38,7 @@ func construct(t *testing.T, files map[string]string, testNamer namer.Namer) (*p
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
orderer := namer.Orderer{testNamer}
|
||||
orderer := namer.Orderer{Namer: testNamer}
|
||||
o := orderer.OrderUniverse(u)
|
||||
return b, u, o
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func calledOnce(h bool, ret runtime.Object, err error) (<-chan struct{}, func(co
|
|||
|
||||
func TestRegister_withUnknownNode(t *testing.T) {
|
||||
fc := &core.Fake{}
|
||||
nodes := &fakeNodes{&fake.FakeNodes{&fake.FakeCore{Fake: fc}}}
|
||||
nodes := &fakeNodes{&fake.FakeNodes{Fake: &fake.FakeCore{Fake: fc}}}
|
||||
createCalled, createOnce := calledOnce(true, nil, nil)
|
||||
fc.AddReactor("create", "nodes", createOnce)
|
||||
|
||||
|
@ -84,7 +84,7 @@ func TestRegister_withUnknownNode(t *testing.T) {
|
|||
|
||||
func TestRegister_withKnownNode(t *testing.T) {
|
||||
fc := &core.Fake{}
|
||||
nodes := &fakeNodes{&fake.FakeNodes{&fake.FakeCore{Fake: fc}}}
|
||||
nodes := &fakeNodes{&fake.FakeNodes{Fake: &fake.FakeCore{Fake: fc}}}
|
||||
updateCalled, updateOnce := calledOnce(true, nil, nil)
|
||||
fc.AddReactor("update", "nodes", updateOnce)
|
||||
|
||||
|
@ -122,7 +122,7 @@ func TestRegister_withSemiKnownNode(t *testing.T) {
|
|||
// CreateOrUpdate should proceed to attempt an update.
|
||||
|
||||
fc := &core.Fake{}
|
||||
nodes := &fakeNodes{&fake.FakeNodes{&fake.FakeCore{Fake: fc}}}
|
||||
nodes := &fakeNodes{&fake.FakeNodes{Fake: &fake.FakeCore{Fake: fc}}}
|
||||
|
||||
createCalled, createOnce := calledOnce(true, nil, errors.NewAlreadyExists(unversioned.GroupResource{Group: "", Resource: ""}, "nodes"))
|
||||
fc.AddReactor("create", "nodes", createOnce)
|
||||
|
|
|
@ -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 {
|
||||
return *(dp.deadline), true
|
||||
}
|
||||
return time.Time{}, false
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
return errors
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ func TestParseRuntimeConfig(t *testing.T) {
|
|||
|
||||
expectedConfig := test.expectedAPIConfig()
|
||||
if err == nil && !reflect.DeepEqual(actualDisablers, expectedConfig) {
|
||||
t.Fatalf("%v: unexpected apiResourceDisablers. Actual: %q\n expected: %q", test.runtimeConfig, actualDisablers, expectedConfig)
|
||||
t.Fatalf("%v: unexpected apiResourceDisablers. Actual: %v\n expected: %v", test.runtimeConfig, actualDisablers, expectedConfig)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
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
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 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"
|
||||
|
||||
kube::golang::setup_env
|
||||
|
||||
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
|
||||
targets=("...")
|
||||
fi
|
||||
|
||||
# Filter silly "exit status 1" lines and send main output to stdout.
|
||||
#
|
||||
# This is tricky - pipefail means any non-zero exit in a pipeline is reported,
|
||||
# and errexit exits on error. Turning that into an || expression blocks the
|
||||
# errexit. But $? is still not useful because grep will return an error when it
|
||||
# receives no input, which is exactly what go vet produces on success. In
|
||||
# short, if go vet fails (produces output), grep will succeed, but if go vet
|
||||
# succeeds (produces no output) grep will fail. Then we just look at
|
||||
# PIPESTATUS[0] which is go's exit code.
|
||||
rc=0
|
||||
go vet "${goflags[@]:+${goflags[@]}}" "${targets[@]/#/./}" 2>&1 \
|
||||
| grep -v "^exit status " \
|
||||
|| rc=${PIPESTATUS[0]}
|
||||
exit "${rc}"
|
|
@ -84,7 +84,6 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
|
|||
if err != nil {
|
||||
t.Errorf("0: %v: %v\nCodec: %v\nData: %s\nSource: %#v", name, err, codec, dataAsString(data), printer.Sprintf("%#v", item))
|
||||
panic("failed")
|
||||
return
|
||||
}
|
||||
if !api.Semantic.DeepEqual(item, obj2) {
|
||||
t.Errorf("\n1: %v: diff: %v\nCodec: %v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectGoPrintDiff(item, obj2), codec, printer.Sprintf("%#v", item), dataAsString(data), printer.Sprintf("%#v", obj2))
|
||||
|
|
|
@ -56,17 +56,17 @@ type Clientset struct {
|
|||
}
|
||||
|
||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
return &fakediscovery.FakeDiscovery{&c.Fake}
|
||||
return &fakediscovery.FakeDiscovery{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
var _ clientset.Interface = &Clientset{}
|
||||
|
||||
// Core retrieves the CoreClient
|
||||
func (c *Clientset) Core() v1core.CoreInterface {
|
||||
return &fakev1core.FakeCore{&c.Fake}
|
||||
return &fakev1core.FakeCore{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// Extensions retrieves the ExtensionsClient
|
||||
func (c *Clientset) Extensions() v1beta1extensions.ExtensionsInterface {
|
||||
return &fakev1beta1extensions.FakeExtensions{&c.Fake}
|
||||
return &fakev1beta1extensions.FakeExtensions{Fake: &c.Fake}
|
||||
}
|
||||
|
|
|
@ -221,9 +221,12 @@ func NewTestFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
|
|||
|
||||
func NewMixedFactory(apiClient resource.RESTClient) (*cmdutil.Factory, *testFactory, runtime.Codec) {
|
||||
f, t, c := NewTestFactory()
|
||||
var multiRESTMapper meta.MultiRESTMapper
|
||||
multiRESTMapper = append(multiRESTMapper, t.Mapper)
|
||||
multiRESTMapper = append(multiRESTMapper, testapi.Default.RESTMapper())
|
||||
f.Object = func(discovery bool) (meta.RESTMapper, runtime.ObjectTyper) {
|
||||
priorityRESTMapper := meta.PriorityRESTMapper{
|
||||
Delegate: meta.MultiRESTMapper{t.Mapper, testapi.Default.RESTMapper()},
|
||||
Delegate: multiRESTMapper,
|
||||
ResourcePriority: []unversioned.GroupVersionResource{
|
||||
{Group: meta.AnyGroup, Version: "v1", Resource: meta.AnyResource},
|
||||
},
|
||||
|
|
|
@ -1696,7 +1696,7 @@ func describeNodeResource(nodeNonTerminatedPodsList *api.PodList, node *api.Node
|
|||
memoryReq.String(), int64(fractionMemoryReq), memoryLimit.String(), int64(fractionMemoryLimit))
|
||||
}
|
||||
|
||||
fmt.Fprint(out, "Allocated resources:\n (Total limits may be over 100%, i.e., overcommitted. More info: http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md)\n CPU Requests\tCPU Limits\tMemory Requests\tMemory Limits\n")
|
||||
fmt.Fprint(out, "Allocated resources:\n (Total limits may be over 100 percent, i.e., overcommitted. More info: http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md)\n CPU Requests\tCPU Limits\tMemory Requests\tMemory Limits\n")
|
||||
fmt.Fprint(out, " ------------\t----------\t---------------\t-------------\n")
|
||||
reqs, limits, err := getPodsTotalRequestsAndLimits(nodeNonTerminatedPodsList)
|
||||
if err != nil {
|
||||
|
|
|
@ -347,7 +347,7 @@ func TestJobScaleFailsPreconditions(t *testing.T) {
|
|||
Parallelism: &ten,
|
||||
},
|
||||
})
|
||||
scaler := JobScaler{&testclient.FakeExperimental{fake}}
|
||||
scaler := JobScaler{&testclient.FakeExperimental{Fake: fake}}
|
||||
preconditions := ScalePrecondition{2, ""}
|
||||
count := uint(3)
|
||||
name := "foo"
|
||||
|
@ -586,7 +586,7 @@ func TestDeploymentScaleFailsPreconditions(t *testing.T) {
|
|||
Replicas: 10,
|
||||
},
|
||||
})
|
||||
scaler := DeploymentScaler{&testclient.FakeExperimental{fake}}
|
||||
scaler := DeploymentScaler{&testclient.FakeExperimental{Fake: fake}}
|
||||
preconditions := ScalePrecondition{2, ""}
|
||||
count := uint(3)
|
||||
name := "foo"
|
||||
|
|
|
@ -704,7 +704,7 @@ func TestSimpleStop(t *testing.T) {
|
|||
}
|
||||
actions := fake.Actions()
|
||||
if len(test.actions) != len(actions) {
|
||||
t.Errorf("unexpected actions: %v; expected %v (%s)", fake.Actions, test.actions, test.test)
|
||||
t.Errorf("unexpected actions: %v; expected %v (%s)", actions, test.actions, test.test)
|
||||
}
|
||||
for i, action := range actions {
|
||||
testAction := test.actions[i]
|
||||
|
|
|
@ -70,7 +70,7 @@ func TestBackoffReset(t *testing.T) {
|
|||
lastUpdate := tc.Now()
|
||||
tc.Step(2*maxDuration + step) // time += 11s, 11 > 2*maxDuration
|
||||
if b.IsInBackOffSince(id, lastUpdate) {
|
||||
t.Errorf("now=%s lastUpdate=%s (%s) expected Backoff reset got %s b.lastUpdate=%s", tc.Now(), startTime, tc.Now().Sub(lastUpdate), b.Get(id))
|
||||
t.Errorf("expected to not be in Backoff after reset (start=%s, now=%s, lastUpdate=%s), got %s", startTime, tc.Now(), lastUpdate, b.Get(id))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ func TestHandshake(t *testing.T) {
|
|||
|
||||
if len(test.expectedProtocol) == 0 {
|
||||
if len(w.Header()[HeaderProtocolVersion]) > 0 {
|
||||
t.Errorf("%s: unexpected protocol version response header: %s", w.Header()[HeaderProtocolVersion])
|
||||
t.Errorf("%s: unexpected protocol version response header: %s", name, w.Header()[HeaderProtocolVersion])
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -165,7 +165,6 @@ func findNodesThatFit(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.No
|
|||
err := fmt.Errorf("SchedulerPredicates failed due to %v, which is unexpected.", err)
|
||||
return api.NodeList{}, FailedPredicateMap{}, err
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if fits {
|
||||
|
|
|
@ -155,7 +155,7 @@ func (es *e2eService) startServer(cmd *healthCheckCommand) error {
|
|||
go func() {
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
cmdErrorChan <- fmt.Errorf("%s Exited with status %v. Output:\n%s", cmd, err, *cmd.OutputBuffer)
|
||||
cmdErrorChan <- fmt.Errorf("%s Exited with status %v. Output:\n%v", cmd, err, *cmd.OutputBuffer)
|
||||
}
|
||||
close(cmdErrorChan)
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue