From 75c0987de3cb9a0380873745f68dea2f0835a7a2 Mon Sep 17 00:00:00 2001 From: Ismayil Mirzali Date: Tue, 18 Jan 2022 12:03:08 +0200 Subject: [PATCH] client-go: refactor: Fix styling issues (#107248) * client-go: Remove unreachable return Due to the way the switch statement is done, the return at the end of the function will neverbe reached. Signed-off-by: Ismayil Mirzali * client-go: Refactor for clarity Fixed one instance where the error message should be lowercase. Made the fields in the struct literal more explicit Signed-off-by: Ismayil Mirzali --- staging/src/k8s.io/client-go/tools/cache/reflector.go | 6 +++--- staging/src/k8s.io/client-go/tools/cache/reflector_test.go | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/client-go/tools/cache/reflector.go b/staging/src/k8s.io/client-go/tools/cache/reflector.go index a174628576d..84f242116b9 100644 --- a/staging/src/k8s.io/client-go/tools/cache/reflector.go +++ b/staging/src/k8s.io/client-go/tools/cache/reflector.go @@ -231,7 +231,7 @@ var ( // Used to indicate that watching stopped because of a signal from the stop // channel passed in from a client of the reflector. - errorStopRequested = errors.New("Stop requested") + errorStopRequested = errors.New("stop requested") ) // resyncChan returns a channel which will receive something when a resync is @@ -258,7 +258,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { options := metav1.ListOptions{ResourceVersion: r.relistResourceVersion()} if err := func() error { - initTrace := trace.New("Reflector ListAndWatch", trace.Field{"name", r.name}) + initTrace := trace.New("Reflector ListAndWatch", trace.Field{Key: "name", Value: r.name}) defer initTrace.LogIfLong(10 * time.Second) var list runtime.Object var paginatedResult bool @@ -319,7 +319,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { panic(r) case <-listCh: } - initTrace.Step("Objects listed", trace.Field{"error", err}) + initTrace.Step("Objects listed", trace.Field{Key: "error", Value: err}) if err != nil { klog.Warningf("%s: failed to list %v: %v", r.name, r.expectedTypeName, err) return fmt.Errorf("failed to list %v: %v", r.expectedTypeName, err) diff --git a/staging/src/k8s.io/client-go/tools/cache/reflector_test.go b/staging/src/k8s.io/client-go/tools/cache/reflector_test.go index 49f76bf061d..9f35b682cfc 100644 --- a/staging/src/k8s.io/client-go/tools/cache/reflector_test.go +++ b/staging/src/k8s.io/client-go/tools/cache/reflector_test.go @@ -813,7 +813,6 @@ func TestReflectorFullListIfExpired(t *testing.T) { t.Error(err) return nil, err } - return nil, nil }, } r := NewReflector(lw, &v1.Pod{}, s, 0)