Skip to content

Commit 2896fb0

Browse files
authored
Merge pull request kubernetes#83711 from tanjunchen/fix-staticcheck-test/e2e/network
fix staticcheck failures in test/e2e/common directory
2 parents d379ab2 + 33dda68 commit 2896fb0

File tree

9 files changed

+17
-27
lines changed

9 files changed

+17
-27
lines changed

hack/.staticcheck_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ test/e2e/apimachinery
7676
test/e2e/apps
7777
test/e2e/auth
7878
test/e2e/autoscaling
79-
test/e2e/common
8079
test/e2e/instrumentation/logging/stackdriver
8180
test/e2e/instrumentation/monitoring
8281
test/e2e/manifest

test/e2e/common/autoscaling_utils.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ var (
7070
KindRC = schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"}
7171
KindDeployment = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "Deployment"}
7272
KindReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "ReplicaSet"}
73-
subresource = "scale"
7473
)
7574

7675
/*
@@ -472,7 +471,6 @@ func runServiceAndWorkloadForResourceConsumer(c clientset.Interface, ns, name st
472471
switch kind {
473472
case KindRC:
474473
framework.ExpectNoError(framework.RunRC(rcConfig))
475-
break
476474
case KindDeployment:
477475
dpConfig := testutils.DeploymentConfig{
478476
RCConfig: rcConfig,
@@ -481,14 +479,12 @@ func runServiceAndWorkloadForResourceConsumer(c clientset.Interface, ns, name st
481479
dpConfig.NodeDumpFunc = framework.DumpNodeDebugInfo
482480
dpConfig.ContainerDumpFunc = framework.LogFailedContainers
483481
framework.ExpectNoError(testutils.RunDeployment(dpConfig))
484-
break
485482
case KindReplicaSet:
486483
rsConfig := testutils.ReplicaSetConfig{
487484
RCConfig: rcConfig,
488485
}
489486
ginkgo.By(fmt.Sprintf("creating replicaset %s in namespace %s", rsConfig.Name, rsConfig.Namespace))
490487
framework.ExpectNoError(replicaset.RunReplicaSet(rsConfig))
491-
break
492488
default:
493489
framework.Failf(invalidKind)
494490
}

test/e2e/common/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"fmt"
2121
"time"
2222

23-
"k8s.io/api/core/v1"
23+
v1 "k8s.io/api/core/v1"
2424
"k8s.io/apimachinery/pkg/api/errors"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/apimachinery/pkg/util/uuid"

test/e2e/common/container_probe.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
104104
p, err := podClient.Get(p.Name, metav1.GetOptions{})
105105
framework.ExpectNoError(err)
106106

107-
isReady, err := testutils.PodRunningReady(p)
107+
isReady, _ := testutils.PodRunningReady(p)
108108
gomega.Expect(isReady).NotTo(gomega.BeTrue(), "pod should be not ready")
109109

110110
restartCount := getRestartCount(p)
@@ -269,7 +269,7 @@ func GetContainerStartedTime(p *v1.Pod, containerName string) (time.Time, error)
269269
continue
270270
}
271271
if status.State.Running == nil {
272-
return time.Time{}, fmt.Errorf("Container is not running")
272+
return time.Time{}, fmt.Errorf("container is not running")
273273
}
274274
return status.State.Running.StartedAt.Time, nil
275275
}
@@ -282,7 +282,7 @@ func GetTransitionTimeForReadyCondition(p *v1.Pod) (time.Time, error) {
282282
return cond.LastTransitionTime.Time, nil
283283
}
284284
}
285-
return time.Time{}, fmt.Errorf("No ready condition can be found for pod")
285+
return time.Time{}, fmt.Errorf("no ready condition can be found for pod")
286286
}
287287

288288
func getRestartCount(p *v1.Pod) int {

test/e2e/common/expansion.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
377377
}
378378

379379
ginkgo.By("creating the pod with failed condition")
380-
var podClient *framework.PodClient
381-
podClient = f.PodClient()
380+
var podClient *framework.PodClient = f.PodClient()
382381
pod = podClient.Create(pod)
383382

384383
err := e2epod.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
@@ -469,8 +468,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
469468
}
470469

471470
ginkgo.By("creating the pod")
472-
var podClient *framework.PodClient
473-
podClient = f.PodClient()
471+
var podClient *framework.PodClient = f.PodClient()
474472
pod = podClient.Create(pod)
475473

476474
ginkgo.By("waiting for pod running")
@@ -607,8 +605,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
607605

608606
// Start pod
609607
ginkgo.By(fmt.Sprintf("Creating pod %s", pod.Name))
610-
var podClient *framework.PodClient
611-
podClient = f.PodClient()
608+
var podClient *framework.PodClient = f.PodClient()
612609
pod = podClient.Create(pod)
613610
defer func() {
614611
e2epod.DeletePodWithWait(f.ClientSet, pod)
@@ -640,9 +637,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
640637
})
641638

642639
func testPodFailSubpath(f *framework.Framework, pod *v1.Pod) {
643-
644-
var podClient *framework.PodClient
645-
podClient = f.PodClient()
640+
var podClient *framework.PodClient = f.PodClient()
646641
pod = podClient.Create(pod)
647642

648643
defer func() {

test/e2e/common/kubelet_etc_hosts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"time"
2222

2323
"github.com/onsi/ginkgo"
24-
"k8s.io/api/core/v1"
24+
v1 "k8s.io/api/core/v1"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/klog"
2727
"k8s.io/kubernetes/test/e2e/framework"

test/e2e/common/pods.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
"golang.org/x/net/websocket"
2828

29-
v1 "k8s.io/api/core/v1"
29+
"k8s.io/api/core/v1"
3030
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3131
"k8s.io/apimachinery/pkg/labels"
3232
"k8s.io/apimachinery/pkg/runtime"
@@ -263,7 +263,7 @@ var _ = framework.KubeDescribe("Pods", func() {
263263
select {
264264
case <-listCompleted:
265265
select {
266-
case event, _ := <-w.ResultChan():
266+
case event := <-w.ResultChan():
267267
if event.Type != watch.Added {
268268
framework.Failf("Failed to observe pod creation: %v", event)
269269
}
@@ -313,7 +313,7 @@ var _ = framework.KubeDescribe("Pods", func() {
313313
timer := time.After(framework.DefaultPodDeletionTimeout)
314314
for !deleted {
315315
select {
316-
case event, _ := <-w.ResultChan():
316+
case event := <-w.ResultChan():
317317
switch event.Type {
318318
case watch.Deleted:
319319
lastPod = event.Object.(*v1.Pod)
@@ -604,10 +604,10 @@ var _ = framework.KubeDescribe("Pods", func() {
604604
buf.Write(msg[1:])
605605
}
606606
if buf.Len() == 0 {
607-
return fmt.Errorf("Unexpected output from server")
607+
return fmt.Errorf("unexpected output from server")
608608
}
609609
if !strings.Contains(buf.String(), "remote execution test") {
610-
return fmt.Errorf("Expected to find 'remote execution test' in %q", buf.String())
610+
return fmt.Errorf("expected to find 'remote execution test' in %q", buf.String())
611611
}
612612
return nil
613613
}, time.Minute, 10*time.Second).Should(gomega.BeNil())

test/e2e/common/projected_combined.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ var _ = ginkgo.Describe("[sig-storage] Projected combined", func() {
8686
},
8787
}
8888
f.TestContainerOutput("Check all projections for projected volume plugin", pod, 0, []string{
89-
fmt.Sprintf("%s", podName),
89+
podName,
9090
"secret-value-1",
9191
"configmap-value-1",
9292
})

test/e2e/common/security_context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
124124
framework.SkipIfNodeOSDistroIs("windows")
125125
name := "explicit-nonroot-uid"
126126
pod := makeNonRootPod(name, rootImage, pointer.Int64Ptr(1234))
127-
pod = podClient.Create(pod)
127+
podClient.Create(pod)
128128

129129
podClient.WaitForSuccess(name, framework.PodStartTimeout)
130130
framework.ExpectNoError(podClient.MatchContainerOutput(name, name, "1234"))
@@ -144,7 +144,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
144144
ginkgo.It("should run with an image specified user ID", func() {
145145
name := "implicit-nonroot-uid"
146146
pod := makeNonRootPod(name, nonRootImage, nil)
147-
pod = podClient.Create(pod)
147+
podClient.Create(pod)
148148

149149
podClient.WaitForSuccess(name, framework.PodStartTimeout)
150150
framework.ExpectNoError(podClient.MatchContainerOutput(name, name, "1234"))

0 commit comments

Comments
 (0)