mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #82486 from haoshuwei/fix-ineffassign
Fix ineffassign
This commit is contained in:
commit
9586c602f2
@ -197,9 +197,7 @@ vendor/k8s.io/apiserver/pkg/storage
|
||||
vendor/k8s.io/apiserver/pkg/storage/cacher
|
||||
vendor/k8s.io/apiserver/pkg/storage/etcd3
|
||||
vendor/k8s.io/apiserver/pkg/storage/tests
|
||||
vendor/k8s.io/apiserver/pkg/storage/value/encrypt/aes
|
||||
vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope
|
||||
vendor/k8s.io/apiserver/pkg/storage/value/encrypt/secretbox
|
||||
vendor/k8s.io/apiserver/pkg/util/webhook
|
||||
vendor/k8s.io/apiserver/pkg/util/wsstream
|
||||
vendor/k8s.io/apiserver/plugin/pkg/authenticator/token/oidc
|
||||
|
@ -620,6 +620,9 @@ func TestPluginNewMounter(t *testing.T) {
|
||||
if csiClient == nil {
|
||||
t.Error("mounter csiClient is nil")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if csiMounter.volumeLifecycleMode != test.volumeLifecycleMode {
|
||||
t.Error("unexpected driver mode:", csiMounter.volumeLifecycleMode)
|
||||
}
|
||||
|
@ -3083,6 +3083,9 @@ func TestDelete(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
res, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
@ -3115,6 +3118,9 @@ func TestDeleteWithOptions(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
res, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
@ -3152,6 +3158,9 @@ func TestDeleteWithOptionsQuery(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID+"?gracePeriodSeconds="+strconv.FormatInt(grace, 10), nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
res, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
@ -3192,6 +3201,9 @@ func TestDeleteWithOptionsQueryAndBody(t *testing.T) {
|
||||
}
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID+"?gracePeriodSeconds="+strconv.FormatInt(grace+10, 10), bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
res, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
@ -3228,6 +3240,9 @@ func TestDeleteInvokesAdmissionControl(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3251,6 +3266,9 @@ func TestDeleteMissing(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3291,6 +3309,9 @@ func TestUpdate(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PUT", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3333,6 +3354,9 @@ func TestUpdateInvokesAdmissionControl(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PUT", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3366,6 +3390,9 @@ func TestUpdateRequiresMatchingName(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PUT", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3400,6 +3427,9 @@ func TestUpdateAllowsMissingNamespace(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PUT", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3441,6 +3471,9 @@ func TestUpdateDisallowsMismatchedNamespaceOnError(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PUT", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3480,6 +3513,9 @@ func TestUpdatePreventsMismatchedNamespace(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PUT", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@ -3514,6 +3550,9 @@ func TestUpdateMissing(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PUT", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@ -53,6 +53,9 @@ func TestPatch(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PATCH", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader([]byte(`{"labels":{"foo":"bar"}}`)))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/merge-patch+json; charset=UTF-8")
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
@ -94,6 +97,9 @@ func TestForbiddenForceOnNonApply(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PATCH", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader([]byte(`{"labels":{"foo":"bar"}}`)))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/merge-patch+json; charset=UTF-8")
|
||||
_, err = client.Do(request)
|
||||
if err != nil {
|
||||
@ -101,6 +107,9 @@ func TestForbiddenForceOnNonApply(t *testing.T) {
|
||||
}
|
||||
|
||||
request, err = http.NewRequest("PATCH", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID+"?force=true", bytes.NewReader([]byte(`{"labels":{"foo":"bar"}}`)))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/merge-patch+json; charset=UTF-8")
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
@ -111,6 +120,9 @@ func TestForbiddenForceOnNonApply(t *testing.T) {
|
||||
}
|
||||
|
||||
request, err = http.NewRequest("PATCH", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID+"?force=false", bytes.NewReader([]byte(`{"labels":{"foo":"bar"}}`)))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/merge-patch+json; charset=UTF-8")
|
||||
response, err = client.Do(request)
|
||||
if err != nil {
|
||||
@ -140,6 +152,9 @@ func TestPatchRequiresMatchingName(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
request, err := http.NewRequest("PATCH", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader([]byte(`{"metadata":{"name":"idbar"}}`)))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/merge-patch+json")
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
|
@ -35,7 +35,7 @@ func TestNamespaceContext(t *testing.T) {
|
||||
}
|
||||
|
||||
ctx = NewContext()
|
||||
result, ok = NamespaceFrom(ctx)
|
||||
_, ok = NamespaceFrom(ctx)
|
||||
if ok {
|
||||
t.Fatalf("Should not be ok because there is no namespace on the context")
|
||||
}
|
||||
|
@ -604,6 +604,9 @@ func TestWatchHTTPErrors(t *testing.T) {
|
||||
req, _ := http.NewRequest("GET", dest.String(), nil)
|
||||
client := http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
errStatus := errors.NewInternalError(fmt.Errorf("we got an error")).Status()
|
||||
watcher.Error(&errStatus)
|
||||
watcher.Stop()
|
||||
@ -728,6 +731,9 @@ func TestWatchHTTPTimeout(t *testing.T) {
|
||||
req, _ := http.NewRequest("GET", dest.String(), nil)
|
||||
client := http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
watcher.Add(&apitesting.Simple{TypeMeta: metav1.TypeMeta{APIVersion: newGroupVersion.String()}})
|
||||
|
||||
// Make sure we can actually watch an endpoint
|
||||
|
@ -316,13 +316,13 @@ func TestStoreCreate(t *testing.T) {
|
||||
}
|
||||
|
||||
// create the object with denying admission
|
||||
objA, err := registry.Create(testContext, podA, denyCreateValidation, &metav1.CreateOptions{})
|
||||
_, err := registry.Create(testContext, podA, denyCreateValidation, &metav1.CreateOptions{})
|
||||
if err == nil {
|
||||
t.Errorf("Expected admission error: %v", err)
|
||||
}
|
||||
|
||||
// create the object
|
||||
objA, err = registry.Create(testContext, podA, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
||||
objA, err := registry.Create(testContext, podA, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
@ -1335,6 +1335,9 @@ func TestStoreDeletionPropagation(t *testing.T) {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
_, _, err = registry.Delete(testContext, pod.Name, rest.ValidateAllObjectFunc, tc.options)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
obj, err := registry.Get(testContext, pod.Name, &metav1.GetOptions{})
|
||||
if tc.expectedNotFound {
|
||||
if err == nil || !errors.IsNotFound(err) {
|
||||
|
@ -54,7 +54,7 @@ func TestInputStreamReader(t *testing.T) {
|
||||
return
|
||||
}
|
||||
defer readCloser.Close()
|
||||
result, err := ioutil.ReadAll(readCloser)
|
||||
result, _ := ioutil.ReadAll(readCloser)
|
||||
if string(result) != resultString {
|
||||
t.Errorf("Stream content does not match. Got: %s. Expected: %s.", string(result), resultString)
|
||||
}
|
||||
@ -118,7 +118,7 @@ func TestInputStreamTransport(t *testing.T) {
|
||||
return
|
||||
}
|
||||
defer readCloser.Close()
|
||||
result, err := ioutil.ReadAll(readCloser)
|
||||
result, _ := ioutil.ReadAll(readCloser)
|
||||
if string(result) != message {
|
||||
t.Errorf("Stream content does not match. Got: %s. Expected: %s.", string(result), message)
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func TestGCMKeyRotation(t *testing.T) {
|
||||
}
|
||||
|
||||
// verify changing the context fails storage
|
||||
from, stale, err = p.TransformFromStorage(out, value.DefaultContext([]byte("incorrect_context")))
|
||||
_, _, err = p.TransformFromStorage(out, value.DefaultContext([]byte("incorrect_context")))
|
||||
if err == nil {
|
||||
t.Fatalf("expected unauthenticated data")
|
||||
}
|
||||
@ -130,7 +130,7 @@ func TestCBCKeyRotation(t *testing.T) {
|
||||
}
|
||||
|
||||
// verify changing the context fails storage
|
||||
from, stale, err = p.TransformFromStorage(out, value.DefaultContext([]byte("incorrect_context")))
|
||||
_, _, err = p.TransformFromStorage(out, value.DefaultContext([]byte("incorrect_context")))
|
||||
if err != nil {
|
||||
t.Fatalf("CBC mode does not support authentication: %v", err)
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func TestSecretboxKeyRotation(t *testing.T) {
|
||||
|
||||
// verify changing the context does not fails storage
|
||||
// Secretbox is not currently an authenticating store
|
||||
from, stale, err = p.TransformFromStorage(out, value.DefaultContext([]byte("incorrect_context")))
|
||||
_, _, err = p.TransformFromStorage(out, value.DefaultContext([]byte("incorrect_context")))
|
||||
if err != nil {
|
||||
t.Fatalf("secretbox is not authenticated")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user