From aa6d0f5bb0b5cf9aae239b6a439302fc11c4a89e Mon Sep 17 00:00:00 2001 From: "guiyong.ou" Date: Sun, 24 Jul 2022 21:16:21 +0800 Subject: [PATCH] code cleanup Signed-off-by: guiyong.ou --- .../volume/attachdetach/attach_detach_controller.go | 4 ++-- .../apimachinery/pkg/util/errors/errors_test.go | 12 ++++++------ .../apiserver/pkg/admission/attributes_test.go | 2 +- test/e2e/cloud/gcp/addon_update.go | 2 +- test/e2e/windows/cpu_limits.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/controller/volume/attachdetach/attach_detach_controller.go b/pkg/controller/volume/attachdetach/attach_detach_controller.go index 1a95a0f140e..429ecb15923 100644 --- a/pkg/controller/volume/attachdetach/attach_detach_controller.go +++ b/pkg/controller/volume/attachdetach/attach_detach_controller.go @@ -90,7 +90,7 @@ type TimerConfig struct { // DefaultTimerConfig is the default configuration of Attach/Detach controller // timers. -var DefaultTimerConfig TimerConfig = TimerConfig{ +var DefaultTimerConfig = TimerConfig{ ReconcilerLoopPeriod: 100 * time.Millisecond, ReconcilerMaxWaitForUnmountDuration: 6 * time.Minute, DesiredStateOfWorldPopulatorLoopSleepPeriod: 1 * time.Minute, @@ -895,7 +895,7 @@ func (adc *attachDetachController) addNodeToDswp(node *v1.Node, nodeName types.N keepTerminatedPodVolumes := false if t, ok := node.Annotations[volumeutil.KeepTerminatedPodVolumesAnnotation]; ok { - keepTerminatedPodVolumes = (t == "true") + keepTerminatedPodVolumes = t == "true" } // Node specifies annotation indicating it should be managed by attach diff --git a/staging/src/k8s.io/apimachinery/pkg/util/errors/errors_test.go b/staging/src/k8s.io/apimachinery/pkg/util/errors/errors_test.go index 55d253bb20d..02386aa48dc 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/errors/errors_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/errors/errors_test.go @@ -93,7 +93,7 @@ func TestAggregateWithNil(t *testing.T) { } func TestSingularAggregate(t *testing.T) { - var slice []error = []error{fmt.Errorf("err")} + var slice = []error{fmt.Errorf("err")} var agg Aggregate var err error @@ -121,7 +121,7 @@ func TestSingularAggregate(t *testing.T) { } func TestPluralAggregate(t *testing.T) { - var slice []error = []error{fmt.Errorf("abc"), fmt.Errorf("123")} + var slice = []error{fmt.Errorf("abc"), fmt.Errorf("123")} var agg Aggregate var err error @@ -149,7 +149,7 @@ func TestPluralAggregate(t *testing.T) { } func TestDedupeAggregate(t *testing.T) { - var slice []error = []error{fmt.Errorf("abc"), fmt.Errorf("abc")} + var slice = []error{fmt.Errorf("abc"), fmt.Errorf("abc")} var agg Aggregate agg = NewAggregate(slice) @@ -165,7 +165,7 @@ func TestDedupeAggregate(t *testing.T) { } func TestDedupePluralAggregate(t *testing.T) { - var slice []error = []error{fmt.Errorf("abc"), fmt.Errorf("abc"), fmt.Errorf("123")} + var slice = []error{fmt.Errorf("abc"), fmt.Errorf("abc"), fmt.Errorf("123")} var agg Aggregate agg = NewAggregate(slice) @@ -181,7 +181,7 @@ func TestDedupePluralAggregate(t *testing.T) { } func TestFlattenAndDedupeAggregate(t *testing.T) { - var slice []error = []error{fmt.Errorf("abc"), fmt.Errorf("abc"), NewAggregate([]error{fmt.Errorf("abc")})} + var slice = []error{fmt.Errorf("abc"), fmt.Errorf("abc"), NewAggregate([]error{fmt.Errorf("abc")})} var agg Aggregate agg = NewAggregate(slice) @@ -197,7 +197,7 @@ func TestFlattenAndDedupeAggregate(t *testing.T) { } func TestFlattenAggregate(t *testing.T) { - var slice []error = []error{fmt.Errorf("abc"), fmt.Errorf("abc"), NewAggregate([]error{fmt.Errorf("abc"), fmt.Errorf("def"), NewAggregate([]error{fmt.Errorf("def"), fmt.Errorf("ghi")})})} + var slice = []error{fmt.Errorf("abc"), fmt.Errorf("abc"), NewAggregate([]error{fmt.Errorf("abc"), fmt.Errorf("def"), NewAggregate([]error{fmt.Errorf("def"), fmt.Errorf("ghi")})})} var agg Aggregate agg = NewAggregate(slice) diff --git a/staging/src/k8s.io/apiserver/pkg/admission/attributes_test.go b/staging/src/k8s.io/apiserver/pkg/admission/attributes_test.go index d4f886e30f9..17994a9bff9 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/attributes_test.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/attributes_test.go @@ -39,7 +39,7 @@ func TestAddAnnotation(t *testing.T) { assert.Equal(t, annotations["podsecuritypolicy.admission.k8s.io/validate-policy"], "privileged", "admission annotations should not be overwritten") // test invalid plugin names - var testCases map[string]string = map[string]string{ + var testCases = map[string]string{ "invalid dns subdomain": "INVALID-DNS-Subdomain/policy", "no plugin name": "policy", "no key name": "podsecuritypolicy.admission.k8s.io", diff --git a/test/e2e/cloud/gcp/addon_update.go b/test/e2e/cloud/gcp/addon_update.go index 540d332c222..058eb6ff20e 100644 --- a/test/e2e/cloud/gcp/addon_update.go +++ b/test/e2e/cloud/gcp/addon_update.go @@ -267,7 +267,7 @@ var _ = SIGDescribe("Addon update", func() { svcAddonEnsureExists := "addon-ensure-exists-service.yaml" svcAddonEnsureExistsUpdated := "addon-ensure-exists-service-updated.yaml" - var remoteFiles []stringPair = []stringPair{ + var remoteFiles = []stringPair{ {fmt.Sprintf(reconcileAddonController, addonNsName, serveHostnameImage), rcAddonReconcile}, {fmt.Sprintf(reconcileAddonControllerUpdated, addonNsName, serveHostnameImage), rcAddonReconcileUpdated}, {fmt.Sprintf(deprecatedLabelAddonService, addonNsName), svcAddonDeprecatedLabel}, diff --git a/test/e2e/windows/cpu_limits.go b/test/e2e/windows/cpu_limits.go index e80b34da15b..4e29dee67d0 100644 --- a/test/e2e/windows/cpu_limits.go +++ b/test/e2e/windows/cpu_limits.go @@ -50,7 +50,7 @@ var _ = SIGDescribe("[Feature:Windows] Cpu Resources [Serial]", func() { ginkgo.By("Waiting 2 minutes") time.Sleep(2 * time.Minute) ginkgo.By("Ensuring pods are still running") - var allPods [](*v1.Pod) + var allPods []*v1.Pod for _, p := range podsDecimal { pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get( context.TODO(),