From c3c552821af3432afdaedec607f43ba1efba1be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 28 Jun 2023 21:32:39 +0200 Subject: [PATCH] chore: Fix lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel RĂ¼ger --- internal/store/certificatesigningrequest.go | 4 +++- internal/store/clusterrole.go | 2 +- internal/store/clusterrolebinding.go | 2 +- internal/store/endpointslice.go | 2 ++ internal/store/ingressclass.go | 4 +++- .../store/mutatingwebhookconfiguration.go | 4 +++- internal/store/namespace.go | 4 +++- internal/store/node.go | 4 +++- internal/store/persistentvolume.go | 4 +++- internal/store/storageclass.go | 4 +++- .../store/validatingwebhookconfiguration.go | 4 +++- pkg/app/server_test.go | 2 +- pkg/builder/builder_test.go | 20 +++++++++---------- pkg/metrics_store/metrics_store.go | 4 ++-- 14 files changed, 41 insertions(+), 23 deletions(-) diff --git a/internal/store/certificatesigningrequest.go b/internal/store/certificatesigningrequest.go index 5a4a1b926f..0c26c75639 100644 --- a/internal/store/certificatesigningrequest.go +++ b/internal/store/certificatesigningrequest.go @@ -147,12 +147,14 @@ func wrapCSRFunc(f func(*certv1.CertificateSigningRequest) *metric.Family) func( } } -func createCSRListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createCSRListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.CertificatesV1().CertificateSigningRequests().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.CertificatesV1().CertificateSigningRequests().Watch(context.TODO(), opts) }, } diff --git a/internal/store/clusterrole.go b/internal/store/clusterrole.go index d1d11a2875..167f3f9b17 100644 --- a/internal/store/clusterrole.go +++ b/internal/store/clusterrole.go @@ -132,7 +132,7 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } } -func createClusterRoleListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createClusterRoleListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { opts.FieldSelector = fieldSelector diff --git a/internal/store/clusterrolebinding.go b/internal/store/clusterrolebinding.go index 2a88e612e4..b9a2b921b9 100644 --- a/internal/store/clusterrolebinding.go +++ b/internal/store/clusterrolebinding.go @@ -134,7 +134,7 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st } } -func createClusterRoleBindingListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createClusterRoleBindingListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { opts.FieldSelector = fieldSelector diff --git a/internal/store/endpointslice.go b/internal/store/endpointslice.go index 0b01284468..548e0ef09d 100644 --- a/internal/store/endpointslice.go +++ b/internal/store/endpointslice.go @@ -225,9 +225,11 @@ func wrapEndpointSliceFunc(f func(*discoveryv1.EndpointSlice) *metric.Family) fu func createEndpointSliceListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.DiscoveryV1().EndpointSlices(ns).List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.DiscoveryV1().EndpointSlices(ns).Watch(context.TODO(), opts) }, } diff --git a/internal/store/ingressclass.go b/internal/store/ingressclass.go index 3e67881ef0..bb6c07b1a8 100644 --- a/internal/store/ingressclass.go +++ b/internal/store/ingressclass.go @@ -128,12 +128,14 @@ func wrapIngressClassFunc(f func(*networkingv1.IngressClass) *metric.Family) fun } } -func createIngressClassListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createIngressClassListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.NetworkingV1().IngressClasses().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.NetworkingV1().IngressClasses().Watch(context.TODO(), opts) }, } diff --git a/internal/store/mutatingwebhookconfiguration.go b/internal/store/mutatingwebhookconfiguration.go index 917ca1e799..445e426718 100644 --- a/internal/store/mutatingwebhookconfiguration.go +++ b/internal/store/mutatingwebhookconfiguration.go @@ -85,12 +85,14 @@ var ( } ) -func createMutatingWebhookConfigurationListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createMutatingWebhookConfigurationListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Watch(context.TODO(), opts) }, } diff --git a/internal/store/namespace.go b/internal/store/namespace.go index bf44f472ae..ea9a733a34 100644 --- a/internal/store/namespace.go +++ b/internal/store/namespace.go @@ -169,12 +169,14 @@ func wrapNamespaceFunc(f func(*v1.Namespace) *metric.Family) func(interface{}) * } } -func createNamespaceListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createNamespaceListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.CoreV1().Namespaces().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.CoreV1().Namespaces().Watch(context.TODO(), opts) }, } diff --git a/internal/store/node.go b/internal/store/node.go index e2a1851054..76f46ac6c4 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -489,12 +489,14 @@ func wrapNodeFunc(f func(*v1.Node) *metric.Family) func(interface{}) *metric.Fam } } -func createNodeListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createNodeListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.CoreV1().Nodes().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.CoreV1().Nodes().Watch(context.TODO(), opts) }, } diff --git a/internal/store/persistentvolume.go b/internal/store/persistentvolume.go index 35b7ea071a..a18fb8bd22 100644 --- a/internal/store/persistentvolume.go +++ b/internal/store/persistentvolume.go @@ -338,12 +338,14 @@ func wrapPersistentVolumeFunc(f func(*v1.PersistentVolume) *metric.Family) func( } } -func createPersistentVolumeListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createPersistentVolumeListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.CoreV1().PersistentVolumes().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.CoreV1().PersistentVolumes().Watch(context.TODO(), opts) }, } diff --git a/internal/store/storageclass.go b/internal/store/storageclass.go index f088953f6a..dfb912fd19 100644 --- a/internal/store/storageclass.go +++ b/internal/store/storageclass.go @@ -140,12 +140,14 @@ func wrapStorageClassFunc(f func(*storagev1.StorageClass) *metric.Family) func(i } } -func createStorageClassListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createStorageClassListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.StorageV1().StorageClasses().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.StorageV1().StorageClasses().Watch(context.TODO(), opts) }, } diff --git a/internal/store/validatingwebhookconfiguration.go b/internal/store/validatingwebhookconfiguration.go index da698acdd0..6763523aa9 100644 --- a/internal/store/validatingwebhookconfiguration.go +++ b/internal/store/validatingwebhookconfiguration.go @@ -85,12 +85,14 @@ var ( } ) -func createValidatingWebhookConfigurationListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { +func createValidatingWebhookConfigurationListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher { return &cache.ListWatch{ ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + opts.FieldSelector = fieldSelector return kubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().List(context.TODO(), opts) }, WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + opts.FieldSelector = fieldSelector return kubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().Watch(context.TODO(), opts) }, } diff --git a/pkg/app/server_test.go b/pkg/app/server_test.go index 3611b925ed..2e59474cfb 100644 --- a/pkg/app/server_test.go +++ b/pkg/app/server_test.go @@ -880,7 +880,7 @@ func (f *fooFactory) Name() string { } // CreateClient use fake client set to establish 10 foos. -func (f *fooFactory) CreateClient(cfg *rest.Config) (interface{}, error) { +func (f *fooFactory) CreateClient(_ *rest.Config) (interface{}, error) { fooClient := samplefake.NewSimpleClientset() for i := 0; i < 10; i++ { err := foo(fooClient, i) diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index 7189cb1c66..0ceac21abf 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -63,10 +63,10 @@ func TestBuilderWithCustomStore(t *testing.T) { } } -func customStore(metricFamilies []generator.FamilyGenerator, - expectedType interface{}, - listWatchFunc func(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher, - useAPIServerCache bool, +func customStore(_ []generator.FamilyGenerator, + _ interface{}, + _ func(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher, + _ bool, ) []cache.Store { stores := make([]cache.Store, 0, 2) stores = append(stores, newFakeStore(fakeMetricLists[0])) @@ -84,15 +84,15 @@ type fakeStore struct { metrics []string } -func (s *fakeStore) Add(obj interface{}) error { +func (s *fakeStore) Add(_ interface{}) error { return nil } -func (s *fakeStore) Update(obj interface{}) error { +func (s *fakeStore) Update(_ interface{}) error { return nil } -func (s *fakeStore) Delete(obj interface{}) error { +func (s *fakeStore) Delete(_ interface{}) error { return nil } @@ -109,15 +109,15 @@ func (s *fakeStore) ListKeys() []string { return nil } -func (s *fakeStore) Get(obj interface{}) (item interface{}, exists bool, err error) { +func (s *fakeStore) Get(_ interface{}) (item interface{}, exists bool, err error) { return nil, false, nil } -func (s *fakeStore) GetByKey(key string) (item interface{}, exists bool, err error) { +func (s *fakeStore) GetByKey(_ string) (item interface{}, exists bool, err error) { return nil, false, nil } -func (s *fakeStore) Replace(list []interface{}, _ string) error { +func (s *fakeStore) Replace(_ []interface{}, _ string) error { return nil } diff --git a/pkg/metrics_store/metrics_store.go b/pkg/metrics_store/metrics_store.go index 80d7149781..25b4bb4950 100644 --- a/pkg/metrics_store/metrics_store.go +++ b/pkg/metrics_store/metrics_store.go @@ -113,12 +113,12 @@ func (s *MetricsStore) ListKeys() []string { } // Get implements the Get method of the store interface. -func (s *MetricsStore) Get(obj interface{}) (item interface{}, exists bool, err error) { +func (s *MetricsStore) Get(_ interface{}) (item interface{}, exists bool, err error) { return nil, false, nil } // GetByKey implements the GetByKey method of the store interface. -func (s *MetricsStore) GetByKey(key string) (item interface{}, exists bool, err error) { +func (s *MetricsStore) GetByKey(_ string) (item interface{}, exists bool, err error) { return nil, false, nil }