mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
fix 'go vet' warnings
This commit is contained in:
parent
ea960711ff
commit
95a9098311
@ -132,8 +132,6 @@ func enscope(parent string, spec EnscopeSpec, in interface{}) (out interface{},
|
||||
}
|
||||
}
|
||||
return o, nil
|
||||
default:
|
||||
return in, nil
|
||||
}
|
||||
return in, nil
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func TestRESTMapperVersionAndKindForResource(t *testing.T) {
|
||||
v, k, err := mapper.VersionAndKindForResource(testCase.Resource)
|
||||
hasErr := err != nil
|
||||
if hasErr != testCase.Err {
|
||||
t.Errorf("%d: unexpected error behavior %f: %v", i, testCase.Err, err)
|
||||
t.Errorf("%d: unexpected error behavior %t: %v", i, testCase.Err, err)
|
||||
continue
|
||||
}
|
||||
if v != testCase.APIVersion || k != testCase.Kind {
|
||||
@ -147,7 +147,7 @@ func TestRESTMapperRESTMapping(t *testing.T) {
|
||||
mapping, err := mapper.RESTMapping(testCase.APIVersion, testCase.Kind)
|
||||
hasErr := err != nil
|
||||
if hasErr != testCase.Err {
|
||||
t.Errorf("%d: unexpected error behavior %f: %v", i, testCase.Err, err)
|
||||
t.Errorf("%d: unexpected error behavior %t: %v", i, testCase.Err, err)
|
||||
}
|
||||
if hasErr {
|
||||
continue
|
||||
|
@ -549,7 +549,7 @@ type Status struct {
|
||||
// "Failure" or "Working" status. If this value is empty there
|
||||
// is no information available. A Reason clarifies an HTTP status
|
||||
// code but does not override it.
|
||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the "Failure" or "Working" status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
|
||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the 'Failure' or 'Working' status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
|
||||
// Extended data associated with the reason. Each reason may define its
|
||||
// own extended details. This field is optional and the data returned
|
||||
// is not guaranteed to conform to any schema except that defined by
|
||||
|
@ -511,7 +511,7 @@ type Status struct {
|
||||
// "Failure" or "Working" status. If this value is empty there
|
||||
// is no information available. A Reason clarifies an HTTP status
|
||||
// code but does not override it.
|
||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the "Failure" or "Working" status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
|
||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the 'Failure' or 'Working' status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
|
||||
// Extended data associated with the reason. Each reason may define its
|
||||
// own extended details. This field is optional and the data returned
|
||||
// is not guaranteed to conform to any schema except that defined by
|
||||
|
@ -278,7 +278,7 @@ func TestNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
if response.StatusCode != v.Status {
|
||||
t.Errorf("Expected %d for %s (%s), Got %#v", v.Status, v, k, response)
|
||||
t.Errorf("Expected %d for %s (%s), Got %#v", v.Status, v.Method, k, response)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,13 +143,13 @@ func TestTransformResponse(t *testing.T) {
|
||||
response, created, err := r.transformResponse(test.Response, &http.Request{})
|
||||
hasErr := err != nil
|
||||
if hasErr != test.Error {
|
||||
t.Errorf("%d: unexpected error: %f %v", i, test.Error, err)
|
||||
t.Errorf("%d: unexpected error: %t %v", i, test.Error, err)
|
||||
}
|
||||
if !(test.Data == nil && response == nil) && !reflect.DeepEqual(test.Data, response) {
|
||||
t.Errorf("%d: unexpected response: %#v %#v", i, test.Data, response)
|
||||
}
|
||||
if test.Created != created {
|
||||
t.Errorf("%d: expected created %f, got %f", i, test.Created, created)
|
||||
t.Errorf("%d: expected created %t, got %t", i, test.Created, created)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,7 +196,7 @@ func TestRequestWatch(t *testing.T) {
|
||||
watch, err := testCase.Request.Watch()
|
||||
hasErr := err != nil
|
||||
if hasErr != testCase.Err {
|
||||
t.Errorf("%d: expected %f, got %f: %v", i, testCase.Err, hasErr, err)
|
||||
t.Errorf("%d: expected %t, got %t: %v", i, testCase.Err, hasErr, err)
|
||||
}
|
||||
if hasErr && watch != nil {
|
||||
t.Errorf("%d: watch should be nil when error is returned", i)
|
||||
@ -231,7 +231,7 @@ func TestRequestStream(t *testing.T) {
|
||||
body, err := testCase.Request.Stream()
|
||||
hasErr := err != nil
|
||||
if hasErr != testCase.Err {
|
||||
t.Errorf("%d: expected %f, got %f: %v", i, testCase.Err, hasErr, err)
|
||||
t.Errorf("%d: expected %t, got %t: %v", i, testCase.Err, hasErr, err)
|
||||
}
|
||||
if hasErr && body != nil {
|
||||
t.Errorf("%d: body should be nil when error is returned", i)
|
||||
@ -266,7 +266,7 @@ func TestRequestDo(t *testing.T) {
|
||||
body, err := testCase.Request.Do().Raw()
|
||||
hasErr := err != nil
|
||||
if hasErr != testCase.Err {
|
||||
t.Errorf("%d: expected %f, got %f: %v", i, testCase.Err, hasErr, err)
|
||||
t.Errorf("%d: expected %t, got %t: %v", i, testCase.Err, hasErr, err)
|
||||
}
|
||||
if hasErr && body != nil {
|
||||
t.Errorf("%d: body should be nil when error is returned", i)
|
||||
|
@ -212,7 +212,7 @@ func TestCreateReplica(t *testing.T) {
|
||||
|
||||
manifest := api.ContainerManifest{}
|
||||
if err := api.Scheme.Convert(&controllerSpec.Spec.Template.Spec, &manifest); err != nil {
|
||||
t.Fatalf("unexpected error", err)
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
expectedPod := api.Pod{
|
||||
|
@ -169,10 +169,10 @@ func objDiff(a, b interface{}) string {
|
||||
// An alternate diff attempt, in case json isn't showing you
|
||||
// the difference. (reflect.DeepEqual makes a distinction between
|
||||
// nil and empty slices, for example.)
|
||||
return util.StringDiff(
|
||||
fmt.Sprintf("%#v", a),
|
||||
fmt.Sprintf("%#v", b),
|
||||
)
|
||||
//return util.StringDiff(
|
||||
// fmt.Sprintf("%#v", a),
|
||||
// fmt.Sprintf("%#v", b),
|
||||
//)
|
||||
}
|
||||
|
||||
func runTest(t *testing.T, source interface{}) {
|
||||
|
@ -82,7 +82,7 @@ func ReadUrl(url string, client *http.Client, header *http.Header) (body []byte,
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
err := fmt.Errorf("http status code: %d while fetching url: %v", resp.StatusCode)
|
||||
err := fmt.Errorf("http status code: %d while fetching url %s", resp.StatusCode, url)
|
||||
glog.Errorf("while trying to read %s: %v", url, err)
|
||||
glog.V(2).Infof("body of failing http response: %v", resp.Body)
|
||||
return nil, err
|
||||
|
@ -88,7 +88,7 @@ func TestRESTHelperDelete(t *testing.T) {
|
||||
}
|
||||
err := modifier.Delete("bar", "foo")
|
||||
if (err != nil) != test.Err {
|
||||
t.Errorf("unexpected error: %f %v", test.Err, err)
|
||||
t.Errorf("unexpected error: %t %v", test.Err, err)
|
||||
}
|
||||
if err != nil {
|
||||
continue
|
||||
@ -178,7 +178,7 @@ func TestRESTHelperCreate(t *testing.T) {
|
||||
}
|
||||
err := modifier.Create("bar", test.Modify, data)
|
||||
if (err != nil) != test.Err {
|
||||
t.Errorf("%d: unexpected error: %f %v", i, test.Err, err)
|
||||
t.Errorf("%d: unexpected error: %t %v", i, test.Err, err)
|
||||
}
|
||||
if err != nil {
|
||||
continue
|
||||
@ -253,7 +253,7 @@ func TestRESTHelperGet(t *testing.T) {
|
||||
}
|
||||
obj, err := modifier.Get("bar", "foo", labels.Everything())
|
||||
if (err != nil) != test.Err {
|
||||
t.Errorf("unexpected error: %f %v", test.Err, err)
|
||||
t.Errorf("unexpected error: %t %v", test.Err, err)
|
||||
}
|
||||
if err != nil {
|
||||
continue
|
||||
@ -356,7 +356,7 @@ func TestRESTHelperUpdate(t *testing.T) {
|
||||
}
|
||||
err := modifier.Update("bar", "foo", test.Overwrite, data)
|
||||
if (err != nil) != test.Err {
|
||||
t.Errorf("%d: unexpected error: %f %v", i, test.Err, err)
|
||||
t.Errorf("%d: unexpected error: %t %v", i, test.Err, err)
|
||||
}
|
||||
if err != nil {
|
||||
continue
|
||||
|
@ -390,7 +390,7 @@ func fieldPath(pod *api.BoundPod, container *api.Container) (string, error) {
|
||||
for i := range pod.Spec.Containers {
|
||||
here := &pod.Spec.Containers[i]
|
||||
if here == container {
|
||||
return fmt.Sprintf("spec.containers[%n]", i), nil
|
||||
return fmt.Sprintf("spec.containers[%d]", i), nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("container %#v not found in pod %#v", container, pod)
|
||||
|
@ -192,10 +192,10 @@ func TestRequiresExactMatch(t *testing.T) {
|
||||
for k, v := range testCases {
|
||||
value, found := v.S.RequiresExactMatch(v.Label)
|
||||
if value != v.Value {
|
||||
t.Errorf("%s: expected value %v, got %s", k, v.Value, value)
|
||||
t.Errorf("%s: expected value %s, got %s", k, v.Value, value)
|
||||
}
|
||||
if found != v.Found {
|
||||
t.Errorf("%s: expected found %v, got %s", k, v.Found, found)
|
||||
t.Errorf("%s: expected found %t, got %t", k, v.Found, found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ func (s ConfigSourceEtcd) ProcessChange(response *etcd.Response) {
|
||||
} else if response.Action == "set" {
|
||||
service, err := etcdResponseToService(response)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to parse %s Port: %s", response, err)
|
||||
glog.Errorf("Failed to parse %#v Port: %s", response, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.Mini
|
||||
if status == health.Healthy {
|
||||
result.Items = append(result.Items, minion)
|
||||
} else {
|
||||
glog.Errorf("%s failed a health check, ignoring.", minion)
|
||||
glog.Errorf("%#v failed a health check, ignoring.", minion)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
|
@ -152,7 +152,7 @@ func TestMinionStorageValidUpdate(t *testing.T) {
|
||||
"baz": "home",
|
||||
}
|
||||
if _, err = storage.Update(ctx, minion); err != nil {
|
||||
t.Error("Unexpected error: %v", err)
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ func TestGetFloat(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
val := GetFloatResource(test.res, test.name, test.def)
|
||||
if val != test.expected {
|
||||
t.Errorf("expected: %d found %d", test.expected, val)
|
||||
t.Errorf("expected: %f found %f", test.expected, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,7 +163,7 @@ func TestGetString(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
val := GetStringResource(test.res, test.name, test.def)
|
||||
if val != test.expected {
|
||||
t.Errorf("expected: %d found %d", test.expected, val)
|
||||
t.Errorf("expected: %s found %s", test.expected, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func SetList(list Object, objects []Object) error {
|
||||
} else if src.Type().ConvertibleTo(dest.Type()) {
|
||||
dest.Set(src.Convert(dest.Type()))
|
||||
} else {
|
||||
return fmt.Errorf("item[%v]: Type mismatch: Expected %v, got %v", dest.Type(), src.Type())
|
||||
return fmt.Errorf("item[%d]: Type mismatch: Expected %v, got %v", i, dest.Type(), src.Type())
|
||||
}
|
||||
}
|
||||
items.Set(slice)
|
||||
|
@ -399,7 +399,7 @@ func TestGetIptablesHasCheckCommand(t *testing.T) {
|
||||
t.Errorf("Expected error: %v, Got error: %v", testCase.Err, err)
|
||||
}
|
||||
if err == nil && testCase.Expected != check {
|
||||
t.Errorf("Expected result: %v, Got result: %v")
|
||||
t.Errorf("Expected result: %v, Got result: %v", testCase.Expected, check)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
|
||||
@ -14,8 +16,6 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// +build integration
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
|
Loading…
Reference in New Issue
Block a user