Skip to content

Commit 8bef807

Browse files
committed
fix predeclared linter
Signed-off-by: Tim Ramlot <[email protected]>
1 parent b31be6e commit 8bef807

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

.golangci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ linters:
1515
- musttag
1616
- nilerr
1717
- noctx
18-
- predeclared
1918
- unparam
2019
text: .*
2120
paths: [third_party$, builtin$, examples$]

pkg/datagatherer/k8s/cache.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ func onAdd(log logr.Logger, obj interface{}, dgCache *cache.Cache) {
5656
// onUpdate handles the informer update events, replacing the old object with the new one
5757
// if it's present in the data gatherer's cache, (if the object isn't present, it gets added).
5858
// The cache key is the uid of the object
59-
func onUpdate(log logr.Logger, old, new interface{}, dgCache *cache.Cache) {
60-
item, ok := old.(cacheResource)
59+
func onUpdate(log logr.Logger, oldObj, newObj interface{}, dgCache *cache.Cache) {
60+
item, ok := oldObj.(cacheResource)
6161
if ok {
62-
cacheObject := updateCacheGatheredResource(string(item.GetUID()), new, dgCache)
62+
cacheObject := updateCacheGatheredResource(string(item.GetUID()), newObj, dgCache)
6363
dgCache.Set(string(item.GetUID()), cacheObject, cache.DefaultExpiration)
6464
return
6565
}
66-
logCacheUpdateFailure(log, old, "update")
66+
logCacheUpdateFailure(log, oldObj, "update")
6767
}
6868

6969
// onDelete handles the informer deletion events, updating the object's properties with the deletion

pkg/datagatherer/k8s/cache_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ func TestOnAddCache(t *testing.T) {
5252
getObject("v1", "Service", "testservice", "testns", false),
5353
getObject("foobar/v1", "NotFoo", "notfoo", "testns", false),
5454
},
55-
eventFunc: func(log logr.Logger, old, new interface{}, dgCache *cache.Cache) { onDelete(log, old, dgCache) },
55+
eventFunc: func(log logr.Logger, oldObj, newObj interface{}, dgCache *cache.Cache) {
56+
onDelete(log, oldObj, dgCache)
57+
},
5658
expected: []*api.GatheredResource{
5759
makeGatheredResource(
5860
getObject("foobar/v1", "Foo", "testfoo", "testns", false),

pkg/datagatherer/k8s/dynamic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ func (c *ConfigDynamic) newDataGathererWithClient(ctx context.Context, cl dynami
221221
AddFunc: func(obj interface{}) {
222222
onAdd(log, obj, dgCache)
223223
},
224-
UpdateFunc: func(old, new interface{}) {
225-
onUpdate(log, old, new, dgCache)
224+
UpdateFunc: func(oldObj, newObj interface{}) {
225+
onUpdate(log, oldObj, newObj, dgCache)
226226
},
227227
DeleteFunc: func(obj interface{}) {
228228
onDelete(log, obj, dgCache)

pkg/datagatherer/k8s/dynamic_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ func TestDynamicGatherer_Fetch(t *testing.T) {
672672
defer wg.Done()
673673
time.Sleep(100 * time.Millisecond)
674674
},
675-
UpdateFunc: func(old, new interface{}) {
675+
UpdateFunc: func(oldObj, newObj interface{}) {
676676
defer wg.Done()
677677
time.Sleep(100 * time.Millisecond)
678678
},
@@ -718,8 +718,8 @@ func TestDynamicGatherer_Fetch(t *testing.T) {
718718

719719
for ns, update := range tc.updateObjects {
720720
wg.Add(1)
721-
new := update.(*unstructured.Unstructured)
722-
_, err := cl.Resource(tc.config.GroupVersionResource).Namespace(ns).Update(ctx, new, metav1.UpdateOptions{})
721+
newObj := update.(*unstructured.Unstructured)
722+
_, err := cl.Resource(tc.config.GroupVersionResource).Namespace(ns).Update(ctx, newObj, metav1.UpdateOptions{})
723723
if err != nil {
724724
t.Fatalf("unexpected client update error: %+v", err)
725725
}
@@ -988,7 +988,7 @@ func TestDynamicGathererNativeResources_Fetch(t *testing.T) {
988988
defer wg.Done()
989989
time.Sleep(100 * time.Millisecond)
990990
},
991-
UpdateFunc: func(old, new interface{}) {
991+
UpdateFunc: func(oldObj, newObj interface{}) {
992992
defer wg.Done()
993993
time.Sleep(100 * time.Millisecond)
994994
},
@@ -1033,8 +1033,8 @@ func TestDynamicGathererNativeResources_Fetch(t *testing.T) {
10331033

10341034
for ns, update := range tc.updateObjects {
10351035
wg.Add(1)
1036-
new := update.(*corev1.Pod)
1037-
_, err := clientset.CoreV1().Pods(ns).Update(ctx, new, metav1.UpdateOptions{})
1036+
newObj := update.(*corev1.Pod)
1037+
_, err := clientset.CoreV1().Pods(ns).Update(ctx, newObj, metav1.UpdateOptions{})
10381038
if err != nil {
10391039
t.Fatalf("unexpected client update error: %+v", err)
10401040
}

0 commit comments

Comments
 (0)