mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-04 07:49:35 +00:00 
			
		
		
		
	Merge pull request #86716 from SataQiu/staticcheck-20191230
Fix staticcheck failures of test/integration/scale test/integration/serviceaccount test/integration/serving test/integration/volume
This commit is contained in:
		@@ -35,11 +35,6 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/test/integration/framework"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type subresourceTest struct {
 | 
			
		||||
	resource schema.GroupVersionResource
 | 
			
		||||
	kind     schema.GroupVersionKind
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func makeGVR(group, version, resource string) schema.GroupVersionResource {
 | 
			
		||||
	return schema.GroupVersionResource{Group: group, Version: version, Resource: resource}
 | 
			
		||||
}
 | 
			
		||||
@@ -58,7 +53,7 @@ func TestScaleSubresources(t *testing.T) {
 | 
			
		||||
	})
 | 
			
		||||
	defer tearDown()
 | 
			
		||||
 | 
			
		||||
	resourceLists, err := clientSet.Discovery().ServerResources()
 | 
			
		||||
	_, resourceLists, err := clientSet.Discovery().ServerGroupsAndResources()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -206,10 +201,6 @@ var (
 | 
			
		||||
	}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func setup(t *testing.T) (client kubernetes.Interface, tearDown func()) {
 | 
			
		||||
	return setupWithOptions(t, nil, nil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func setupWithOptions(t *testing.T, instanceOptions *apitesting.TestServerInstanceOptions, flags []string) (client kubernetes.Interface, tearDown func()) {
 | 
			
		||||
	result := apitesting.StartTestServerOrDie(t, instanceOptions, flags, framework.SharedEtcd())
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@ func TestServiceAccountTokenAutoCreate(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Create service account
 | 
			
		||||
	serviceAccount, err := c.CoreV1().ServiceAccounts(ns).Create(&v1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: name}})
 | 
			
		||||
	_, err = c.CoreV1().ServiceAccounts(ns).Create(&v1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: name}})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("Service Account not created: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -145,7 +145,7 @@ func TestServiceAccountTokenAutoCreate(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Trigger creation of a new referenced token
 | 
			
		||||
	serviceAccount, err = c.CoreV1().ServiceAccounts(ns).Get(name, metav1.GetOptions{})
 | 
			
		||||
	serviceAccount, err := c.CoreV1().ServiceAccounts(ns).Get(name, metav1.GetOptions{})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -292,6 +292,9 @@ func testComponent(t *testing.T, tester componentTester, kubeconfig, brokenKubec
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				body, err := ioutil.ReadAll(r.Body)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					t.Fatalf("failed to read response body: %v", err)
 | 
			
		||||
				}
 | 
			
		||||
				defer r.Body.Close()
 | 
			
		||||
				if got, expected := r.StatusCode, *tt.wantSecureCode; got != expected {
 | 
			
		||||
					t.Fatalf("expected http %d at %s of component, got: %d %q", expected, tt.path, got, string(body))
 | 
			
		||||
@@ -307,6 +310,9 @@ func testComponent(t *testing.T, tester componentTester, kubeconfig, brokenKubec
 | 
			
		||||
					t.Fatalf("failed to GET %s from component: %v", tt.path, err)
 | 
			
		||||
				}
 | 
			
		||||
				body, err := ioutil.ReadAll(r.Body)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					t.Fatalf("failed to read response body: %v", err)
 | 
			
		||||
				}
 | 
			
		||||
				defer r.Body.Close()
 | 
			
		||||
				if got, expected := r.StatusCode, *tt.wantInsecureCode; got != expected {
 | 
			
		||||
					t.Fatalf("expected http %d at %s of component, got: %d %q", expected, tt.path, got, string(body))
 | 
			
		||||
 
 | 
			
		||||
@@ -132,8 +132,6 @@ func fakePodWithPVC(name, pvcName, namespace string) (*v1.Pod, *v1.PersistentVol
 | 
			
		||||
	return fakePod, fakePVC
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type podCountFunc func(int) bool
 | 
			
		||||
 | 
			
		||||
var defaultTimerConfig = attachdetach.TimerConfig{
 | 
			
		||||
	ReconcilerLoopPeriod:                              100 * time.Millisecond,
 | 
			
		||||
	ReconcilerMaxWaitForUnmountDuration:               6 * time.Second,
 | 
			
		||||
 
 | 
			
		||||
@@ -666,11 +666,10 @@ func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
			select {
 | 
			
		||||
			case <-stopCh:
 | 
			
		||||
				break
 | 
			
		||||
				return
 | 
			
		||||
			default:
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user