diff --git a/discovery/kubernetes/endpoints.go b/discovery/kubernetes/endpoints.go index b60eef7ab..a2d852215 100644 --- a/discovery/kubernetes/endpoints.go +++ b/discovery/kubernetes/endpoints.go @@ -182,7 +182,7 @@ func convertToEndpoints(o interface{}) (*apiv1.Endpoints, error) { } func endpointsSource(ep *apiv1.Endpoints) string { - return "endpoints/" + ep.ObjectMeta.Namespace + "/" + ep.ObjectMeta.Name + return endpointsSourceFromNamespaceAndName(ep.Namespace, ep.Name) } func endpointsSourceFromNamespaceAndName(namespace, name string) string { diff --git a/discovery/kubernetes/ingress.go b/discovery/kubernetes/ingress.go index c997890a6..592550212 100644 --- a/discovery/kubernetes/ingress.go +++ b/discovery/kubernetes/ingress.go @@ -122,7 +122,7 @@ func convertToIngress(o interface{}) (*v1beta1.Ingress, error) { } func ingressSource(s *v1beta1.Ingress) string { - return "ingress/" + s.Namespace + "/" + s.Name + return ingressSourceFromNamespaceAndName(s.Namespace, s.Name) } func ingressSourceFromNamespaceAndName(namespace, name string) string { diff --git a/discovery/kubernetes/kubernetes.go b/discovery/kubernetes/kubernetes.go index a3aaf509c..0487e0d68 100644 --- a/discovery/kubernetes/kubernetes.go +++ b/discovery/kubernetes/kubernetes.go @@ -155,7 +155,6 @@ func init() { } } -// Copy of discovery.Discoverer to avoid import cycle. // This is only for internal use. type discoverer interface { Run(ctx context.Context, up chan<- []*targetgroup.Group) diff --git a/discovery/kubernetes/kubernetes_test.go b/discovery/kubernetes/kubernetes_test.go index aea7a883e..bcc2fb9bf 100644 --- a/discovery/kubernetes/kubernetes_test.go +++ b/discovery/kubernetes/kubernetes_test.go @@ -117,7 +117,7 @@ func (d k8sDiscoveryTest) Run(t *testing.T) { // Run discoverer and start a goroutine to read results. go d.discovery.Run(ctx, ch) resChan := make(chan map[string]*targetgroup.Group) - go readResultWithoutTimeout(t, ch, d.expectedMaxItems, time.Second, resChan) + go readResultWithTimeout(t, ch, d.expectedMaxItems, time.Second, resChan) dd, ok := d.discovery.(hasSynced) if !ok { @@ -139,9 +139,9 @@ func (d k8sDiscoveryTest) Run(t *testing.T) { } } -// readResultWithoutTimeout reads all targegroups from channel with timeout. +// readResultWithTimeout reads all targegroups from channel with timeout. // It merges targegroups by source and sends the result to result channel. -func readResultWithoutTimeout(t *testing.T, ch <-chan []*targetgroup.Group, max int, timeout time.Duration, resChan chan<- map[string]*targetgroup.Group) { +func readResultWithTimeout(t *testing.T, ch <-chan []*targetgroup.Group, max int, timeout time.Duration, resChan chan<- map[string]*targetgroup.Group) { allTgs := make([][]*targetgroup.Group, 0) Loop: diff --git a/discovery/kubernetes/node.go b/discovery/kubernetes/node.go index d5372df44..2e1e0aaaf 100644 --- a/discovery/kubernetes/node.go +++ b/discovery/kubernetes/node.go @@ -38,8 +38,6 @@ type Node struct { queue *workqueue.Type } -var _ discoverer = &Node{} - // NewNode returns a new node discovery. func NewNode(l log.Logger, inf cache.SharedInformer) *Node { if l == nil { @@ -130,7 +128,7 @@ func convertToNode(o interface{}) (*apiv1.Node, error) { } func nodeSource(n *apiv1.Node) string { - return "node/" + n.Name + return nodeSourceFromName(n.Name) } func nodeSourceFromName(name string) string { diff --git a/discovery/kubernetes/pod.go b/discovery/kubernetes/pod.go index 9f9a2d73f..74e39d41f 100644 --- a/discovery/kubernetes/pod.go +++ b/discovery/kubernetes/pod.go @@ -215,7 +215,7 @@ func (p *Pod) buildPod(pod *apiv1.Pod) *targetgroup.Group { } func podSource(pod *apiv1.Pod) string { - return "pod/" + pod.Namespace + "/" + pod.Name + return podSourceFromNamespaceAndName(pod.Namespace, pod.Name) } func podSourceFromNamespaceAndName(namespace, name string) string { diff --git a/discovery/kubernetes/service.go b/discovery/kubernetes/service.go index ba85a7d6d..ce04a936c 100644 --- a/discovery/kubernetes/service.go +++ b/discovery/kubernetes/service.go @@ -127,7 +127,7 @@ func convertToService(o interface{}) (*apiv1.Service, error) { } func serviceSource(s *apiv1.Service) string { - return "svc/" + s.Namespace + "/" + s.Name + return serviceSourceFromNamespaceAndName(s.Namespace, s.Name) } func serviceSourceFromNamespaceAndName(namespace, name string) string {