lint(revive): fix unused-parameter violations (#7980)

This commit is contained in:
Ville Vesilehto
2026-03-30 03:02:20 +03:00
committed by GitHub
parent 6af8fd46fe
commit 6720959b8b
95 changed files with 245 additions and 244 deletions

View File

@@ -23,25 +23,25 @@ var (
// Mock API connector for testing
type mockAPIConnector struct{}
func (m *mockAPIConnector) PodIndex(ip string) []*object.Pod {
func (m *mockAPIConnector) PodIndex(_ip string) []*object.Pod {
return []*object.Pod{mockPod}
}
// Minimal implementation of other required methods
func (m *mockAPIConnector) ServiceList() []*object.Service { return nil }
func (m *mockAPIConnector) EndpointsList() []*object.Endpoints { return nil }
func (m *mockAPIConnector) ServiceImportList() []*object.ServiceImport { return nil }
func (m *mockAPIConnector) SvcIndex(s string) []*object.Service { return nil }
func (m *mockAPIConnector) SvcIndexReverse(s string) []*object.Service { return nil }
func (m *mockAPIConnector) SvcExtIndexReverse(s string) []*object.Service { return nil }
func (m *mockAPIConnector) SvcImportIndex(s string) []*object.ServiceImport { return nil }
func (m *mockAPIConnector) EpIndex(s string) []*object.Endpoints { return nil }
func (m *mockAPIConnector) EpIndexReverse(s string) []*object.Endpoints { return nil }
func (m *mockAPIConnector) McEpIndex(s string) []*object.MultiClusterEndpoints { return nil }
func (m *mockAPIConnector) GetNodeByName(ctx context.Context, name string) (*api.Node, error) {
func (m *mockAPIConnector) ServiceList() []*object.Service { return nil }
func (m *mockAPIConnector) EndpointsList() []*object.Endpoints { return nil }
func (m *mockAPIConnector) ServiceImportList() []*object.ServiceImport { return nil }
func (m *mockAPIConnector) SvcIndex(_s string) []*object.Service { return nil }
func (m *mockAPIConnector) SvcIndexReverse(_s string) []*object.Service { return nil }
func (m *mockAPIConnector) SvcExtIndexReverse(_s string) []*object.Service { return nil }
func (m *mockAPIConnector) SvcImportIndex(_s string) []*object.ServiceImport { return nil }
func (m *mockAPIConnector) EpIndex(_s string) []*object.Endpoints { return nil }
func (m *mockAPIConnector) EpIndexReverse(_s string) []*object.Endpoints { return nil }
func (m *mockAPIConnector) McEpIndex(_s string) []*object.MultiClusterEndpoints { return nil }
func (m *mockAPIConnector) GetNodeByName(_ctx context.Context, _name string) (*api.Node, error) {
return nil, nil
}
func (m *mockAPIConnector) GetNamespaceByName(name string) (*object.Namespace, error) {
func (m *mockAPIConnector) GetNamespaceByName(_name string) (*object.Namespace, error) {
return nil, nil
}
func (m *mockAPIConnector) Run() {}

View File

@@ -665,8 +665,8 @@ func (dns *dnsControl) GetNamespaceByName(name string) (*object.Namespace, error
return ns, nil
}
func (dns *dnsControl) Add(obj any) { dns.updateModified() }
func (dns *dnsControl) Delete(obj any) { dns.updateModified() }
func (dns *dnsControl) Add(_obj any) { dns.updateModified() }
func (dns *dnsControl) Delete(_obj any) { dns.updateModified() }
func (dns *dnsControl) Update(oldObj, newObj any) { dns.detectChanges(oldObj, newObj) }
// detectChanges detects changes in objects, and updates the modified timestamp

View File

@@ -241,7 +241,7 @@ func createClusterIPSvc(suffix int, client kubernetes.Interface, ip net.IP) {
}, meta.CreateOptions{})
}
func createHeadlessSvc(suffix int, client kubernetes.Interface, ip net.IP) {
func createHeadlessSvc(suffix int, client kubernetes.Interface, _ip net.IP) {
ctx := context.TODO()
client.CoreV1().Services("testns").Create(ctx, &api.Service{
ObjectMeta: meta.ObjectMeta{
@@ -254,7 +254,7 @@ func createHeadlessSvc(suffix int, client kubernetes.Interface, ip net.IP) {
}, meta.CreateOptions{})
}
func createExternalSvc(suffix int, client kubernetes.Interface, ip net.IP) {
func createExternalSvc(suffix int, client kubernetes.Interface, _ip net.IP) {
ctx := context.TODO()
client.CoreV1().Services("testns").Create(ctx, &api.Service{
ObjectMeta: meta.ObjectMeta{
@@ -273,7 +273,7 @@ func createExternalSvc(suffix int, client kubernetes.Interface, ip net.IP) {
}, meta.CreateOptions{})
}
func createMultiClusterHeadlessSvc(suffix int, mcsClient mcsClientset.MulticlusterV1alpha1Interface, ip net.IP) {
func createMultiClusterHeadlessSvc(suffix int, mcsClient mcsClientset.MulticlusterV1alpha1Interface, _ip net.IP) {
ctx := context.TODO()
mcsClient.ServiceImports("testns").Create(ctx, &mcs.ServiceImport{
ObjectMeta: meta.ObjectMeta{

View File

@@ -111,9 +111,9 @@ func (external) EndpointsList() []*object.Endpoints {
}
return eps
}
func (external) GetNodeByName(ctx context.Context, name string) (*api.Node, error) { return nil, nil }
func (external) SvcIndex(s string) []*object.Service { return svcIndexExternal[s] }
func (external) PodIndex(string) []*object.Pod { return nil }
func (external) GetNodeByName(_ctx context.Context, _name string) (*api.Node, error) { return nil, nil }
func (external) SvcIndex(s string) []*object.Service { return svcIndexExternal[s] }
func (external) PodIndex(string) []*object.Pod { return nil }
func (external) GetNamespaceByName(name string) (*object.Namespace, error) {
return &object.Namespace{

View File

@@ -1133,7 +1133,7 @@ func (APIConnServeTest) EndpointsList() []*object.Endpoints {
return eps
}
func (APIConnServeTest) GetNodeByName(ctx context.Context, name string) (*api.Node, error) {
func (APIConnServeTest) GetNodeByName(_ctx context.Context, _name string) (*api.Node, error) {
return &api.Node{
ObjectMeta: meta.ObjectMeta{
Name: "test.node.foo.bar",
@@ -1161,7 +1161,7 @@ type Upstub struct {
}
// Lookup returns a set response
func (t *Upstub) Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error) {
func (t *Upstub) Lookup(_ctx context.Context, _state request.Request, _name string, _typ uint16) (*dns.Msg, error) {
var answer []dns.RR
// if query type is not CNAME, remove any CNAME with same name as qname from the answer
if t.Qtype != dns.TypeCNAME {

View File

@@ -97,7 +97,7 @@ var (
)
// Services implements the ServiceBackend interface.
func (k *Kubernetes) Services(ctx context.Context, state request.Request, exact bool, opt plugin.Options) (svcs []msg.Service, err error) {
func (k *Kubernetes) Services(ctx context.Context, state request.Request, _exact bool, _opt plugin.Options) (svcs []msg.Service, err error) {
// We're looking again at types, which we've already done in ServeDNS, but there are some types k8s just can't answer.
switch state.QType() {
case dns.TypeTXT:
@@ -329,7 +329,7 @@ func (k *Kubernetes) InitKubeCache(ctx context.Context) (onStart func() error, o
}
// Records looks up services in kubernetes.
func (k *Kubernetes) Records(ctx context.Context, state request.Request, exact bool) ([]msg.Service, error) {
func (k *Kubernetes) Records(_ctx context.Context, state request.Request, _exact bool) ([]msg.Service, error) {
multicluster := k.isMultiClusterZone(state.Zone)
r, e := parseRequest(state.Name(), state.Zone, multicluster)
if e != nil {
@@ -674,7 +674,7 @@ func (k *Kubernetes) Serial(state request.Request) uint32 {
}
// MinTTL returns the minimal TTL.
func (k *Kubernetes) MinTTL(state request.Request) uint32 { return k.ttl }
func (k *Kubernetes) MinTTL(_state request.Request) uint32 { return k.ttl }
func (k *Kubernetes) isMultiClusterZone(zone string) bool {
z := plugin.Zones(k.opts.multiclusterZones).Matches(zone)

View File

@@ -330,7 +330,7 @@ func (APIConnServiceTest) McEpIndex(string) []*object.MultiClusterEndpoints {
return eps
}
func (APIConnServiceTest) GetNodeByName(ctx context.Context, name string) (*api.Node, error) {
func (APIConnServiceTest) GetNodeByName(_ctx context.Context, _name string) (*api.Node, error) {
return &api.Node{
ObjectMeta: meta.ObjectMeta{
Name: "test.node.foo.bar",

View File

@@ -94,11 +94,11 @@ func (APIConnTest) EpIndexReverse(ip string) []*object.Endpoints {
return eps
}
func (APIConnTest) GetNodeByName(ctx context.Context, name string) (*api.Node, error) {
func (APIConnTest) GetNodeByName(_ctx context.Context, _name string) (*api.Node, error) {
return &api.Node{}, nil
}
func (APIConnTest) GetNamespaceByName(name string) (*object.Namespace, error) {
func (APIConnTest) GetNamespaceByName(_name string) (*object.Namespace, error) {
return nil, fmt.Errorf("namespace not found")
}

View File

@@ -167,16 +167,16 @@ func (e *Endpoints) DeepCopyObject() runtime.Object {
func (e *Endpoints) GetNamespace() string { return e.Namespace }
// SetNamespace implements the metav1.Object interface.
func (e *Endpoints) SetNamespace(namespace string) {}
func (e *Endpoints) SetNamespace(_namespace string) {}
// GetName implements the metav1.Object interface.
func (e *Endpoints) GetName() string { return e.Name }
// SetName implements the metav1.Object interface.
func (e *Endpoints) SetName(name string) {}
func (e *Endpoints) SetName(_name string) {}
// GetResourceVersion implements the metav1.Object interface.
func (e *Endpoints) GetResourceVersion() string { return e.Version }
// SetResourceVersion implements the metav1.Object interface.
func (e *Endpoints) SetResourceVersion(version string) {}
func (e *Endpoints) SetResourceVersion(_version string) {}

View File

@@ -49,16 +49,16 @@ func (e *MultiClusterEndpoints) DeepCopyObject() runtime.Object {
func (e *MultiClusterEndpoints) GetNamespace() string { return e.Endpoints.GetNamespace() }
// SetNamespace implements the metav1.Object interface.
func (e *MultiClusterEndpoints) SetNamespace(namespace string) {}
func (e *MultiClusterEndpoints) SetNamespace(_namespace string) {}
// GetName implements the metav1.Object interface.
func (e *MultiClusterEndpoints) GetName() string { return e.Endpoints.GetName() }
// SetName implements the metav1.Object interface.
func (e *MultiClusterEndpoints) SetName(name string) {}
func (e *MultiClusterEndpoints) SetName(_name string) {}
// GetResourceVersion implements the metav1.Object interface.
func (e *MultiClusterEndpoints) GetResourceVersion() string { return e.Endpoints.GetResourceVersion() }
// SetResourceVersion implements the metav1.Object interface.
func (e *MultiClusterEndpoints) SetResourceVersion(version string) {}
func (e *MultiClusterEndpoints) SetResourceVersion(_version string) {}

View File

@@ -46,16 +46,16 @@ func (n *Namespace) DeepCopyObject() runtime.Object {
func (n *Namespace) GetNamespace() string { return "" }
// SetNamespace implements the metav1.Object interface.
func (n *Namespace) SetNamespace(namespace string) {}
func (n *Namespace) SetNamespace(_namespace string) {}
// GetName implements the metav1.Object interface.
func (n *Namespace) GetName() string { return n.Name }
// SetName implements the metav1.Object interface.
func (n *Namespace) SetName(name string) {}
func (n *Namespace) SetName(_name string) {}
// GetResourceVersion implements the metav1.Object interface.
func (n *Namespace) GetResourceVersion() string { return n.Version }
// SetResourceVersion implements the metav1.Object interface.
func (n *Namespace) SetResourceVersion(version string) {}
func (n *Namespace) SetResourceVersion(_version string) {}

View File

@@ -38,37 +38,37 @@ func (e *Empty) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKin
func (e *Empty) GetGenerateName() string { return "" }
// SetGenerateName implements the metav1.Object interface.
func (e *Empty) SetGenerateName(name string) {}
func (e *Empty) SetGenerateName(_name string) {}
// GetUID implements the metav1.Object interface.
func (e *Empty) GetUID() types.UID { return "" }
// SetUID implements the metav1.Object interface.
func (e *Empty) SetUID(uid types.UID) {}
func (e *Empty) SetUID(_uid types.UID) {}
// GetGeneration implements the metav1.Object interface.
func (e *Empty) GetGeneration() int64 { return 0 }
// SetGeneration implements the metav1.Object interface.
func (e *Empty) SetGeneration(generation int64) {}
func (e *Empty) SetGeneration(_generation int64) {}
// GetSelfLink implements the metav1.Object interface.
func (e *Empty) GetSelfLink() string { return "" }
// SetSelfLink implements the metav1.Object interface.
func (e *Empty) SetSelfLink(selfLink string) {}
func (e *Empty) SetSelfLink(_selfLink string) {}
// GetCreationTimestamp implements the metav1.Object interface.
func (e *Empty) GetCreationTimestamp() v1.Time { return v1.Time{} }
// SetCreationTimestamp implements the metav1.Object interface.
func (e *Empty) SetCreationTimestamp(timestamp v1.Time) {}
func (e *Empty) SetCreationTimestamp(_timestamp v1.Time) {}
// GetDeletionTimestamp implements the metav1.Object interface.
func (e *Empty) GetDeletionTimestamp() *v1.Time { return &v1.Time{} }
// SetDeletionTimestamp implements the metav1.Object interface.
func (e *Empty) SetDeletionTimestamp(timestamp *v1.Time) {}
func (e *Empty) SetDeletionTimestamp(_timestamp *v1.Time) {}
// GetDeletionGracePeriodSeconds implements the metav1.Object interface.
func (e *Empty) GetDeletionGracePeriodSeconds() *int64 { return nil }
@@ -80,19 +80,19 @@ func (e *Empty) SetDeletionGracePeriodSeconds(*int64) {}
func (e *Empty) GetLabels() map[string]string { return nil }
// SetLabels implements the metav1.Object interface.
func (e *Empty) SetLabels(labels map[string]string) {}
func (e *Empty) SetLabels(_labels map[string]string) {}
// GetAnnotations implements the metav1.Object interface.
func (e *Empty) GetAnnotations() map[string]string { return nil }
// SetAnnotations implements the metav1.Object interface.
func (e *Empty) SetAnnotations(annotations map[string]string) {}
func (e *Empty) SetAnnotations(_annotations map[string]string) {}
// GetFinalizers implements the metav1.Object interface.
func (e *Empty) GetFinalizers() []string { return nil }
// SetFinalizers implements the metav1.Object interface.
func (e *Empty) SetFinalizers(finalizers []string) {}
func (e *Empty) SetFinalizers(_finalizers []string) {}
// GetOwnerReferences implements the metav1.Object interface.
func (e *Empty) GetOwnerReferences() []v1.OwnerReference { return nil }
@@ -104,10 +104,10 @@ func (e *Empty) SetOwnerReferences([]v1.OwnerReference) {}
func (e *Empty) GetZZZ_DeprecatedClusterName() string { return "" }
// SetZZZ_DeprecatedClusterName implements the metav1.Object interface.
func (e *Empty) SetZZZ_DeprecatedClusterName(clusterName string) {}
func (e *Empty) SetZZZ_DeprecatedClusterName(_clusterName string) {}
// GetManagedFields implements the metav1.Object interface.
func (e *Empty) GetManagedFields() []v1.ManagedFieldsEntry { return nil }
// SetManagedFields implements the metav1.Object interface.
func (e *Empty) SetManagedFields(managedFields []v1.ManagedFieldsEntry) {}
func (e *Empty) SetManagedFields(_managedFields []v1.ManagedFieldsEntry) {}

View File

@@ -65,16 +65,16 @@ func (p *Pod) DeepCopyObject() runtime.Object {
func (p *Pod) GetNamespace() string { return p.Namespace }
// SetNamespace implements the metav1.Object interface.
func (p *Pod) SetNamespace(namespace string) {}
func (p *Pod) SetNamespace(_namespace string) {}
// GetName implements the metav1.Object interface.
func (p *Pod) GetName() string { return p.Name }
// SetName implements the metav1.Object interface.
func (p *Pod) SetName(name string) {}
func (p *Pod) SetName(_name string) {}
// GetResourceVersion implements the metav1.Object interface.
func (p *Pod) GetResourceVersion() string { return p.Version }
// SetResourceVersion implements the metav1.Object interface.
func (p *Pod) SetResourceVersion(version string) {}
func (p *Pod) SetResourceVersion(_version string) {}

View File

@@ -105,16 +105,16 @@ func (s *Service) DeepCopyObject() runtime.Object {
func (s *Service) GetNamespace() string { return s.Namespace }
// SetNamespace implements the metav1.Object interface.
func (s *Service) SetNamespace(namespace string) {}
func (s *Service) SetNamespace(_namespace string) {}
// GetName implements the metav1.Object interface.
func (s *Service) GetName() string { return s.Name }
// SetName implements the metav1.Object interface.
func (s *Service) SetName(name string) {}
func (s *Service) SetName(_name string) {}
// GetResourceVersion implements the metav1.Object interface.
func (s *Service) GetResourceVersion() string { return s.Version }
// SetResourceVersion implements the metav1.Object interface.
func (s *Service) SetResourceVersion(version string) {}
func (s *Service) SetResourceVersion(_version string) {}

View File

@@ -80,16 +80,16 @@ func (s *ServiceImport) DeepCopyObject() runtime.Object {
func (s *ServiceImport) GetNamespace() string { return s.Namespace }
// SetNamespace implements the metav1.Object interface.
func (s *ServiceImport) SetNamespace(namespace string) {}
func (s *ServiceImport) SetNamespace(_namespace string) {}
// GetName implements the metav1.Object interface.
func (s *ServiceImport) GetName() string { return s.Name }
// SetName implements the metav1.Object interface.
func (s *ServiceImport) SetName(name string) {}
func (s *ServiceImport) SetName(_name string) {}
// GetResourceVersion implements the metav1.Object interface.
func (s *ServiceImport) GetResourceVersion() string { return s.Version }
// SetResourceVersion implements the metav1.Object interface.
func (s *ServiceImport) SetResourceVersion(version string) {}
func (s *ServiceImport) SetResourceVersion(_version string) {}

View File

@@ -11,7 +11,7 @@ import (
)
// Reverse implements the ServiceBackend interface.
func (k *Kubernetes) Reverse(ctx context.Context, state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error) {
func (k *Kubernetes) Reverse(ctx context.Context, state request.Request, exact bool, _opt plugin.Options) ([]msg.Service, error) {
ip := dnsutil.ExtractAddressFromReverse(state.Name())
if ip == "" {
_, e := k.Records(ctx, state, exact)
@@ -27,7 +27,7 @@ func (k *Kubernetes) Reverse(ctx context.Context, state request.Request, exact b
// serviceRecordForIP gets a service record with a cluster ip matching the ip argument
// If a service cluster ip does not match, it checks all endpoints
func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service {
func (k *Kubernetes) serviceRecordForIP(ip, _name string) []msg.Service {
// First check services with cluster ips
for _, service := range k.APIConn.SvcIndexReverse(ip) {
if len(k.Namespaces) > 0 && !k.namespaceExposed(service.Namespace) {

View File

@@ -137,7 +137,7 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*object.Endpoints {
return nil
}
func (APIConnReverseTest) GetNodeByName(ctx context.Context, name string) (*api.Node, error) {
func (APIConnReverseTest) GetNodeByName(_ctx context.Context, _name string) (*api.Node, error) {
return &api.Node{
ObjectMeta: meta.ObjectMeta{
Name: "test.node.foo.bar",