From 219e477272fe70cd6aedf5a628635461aab290e9 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Wed, 18 Jul 2018 06:07:33 +0200 Subject: [PATCH] Fix some (valid) lint errors (#4287) Signed-off-by: Julius Volz --- discovery/kubernetes/ingress.go | 30 +++++++++++++++--------------- discovery/kubernetes/node.go | 4 ++-- discovery/kubernetes/pod.go | 4 ++-- discovery/kubernetes/service.go | 4 ++-- promql/bench_test.go | 2 +- promql/engine.go | 14 +++++++------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/discovery/kubernetes/ingress.go b/discovery/kubernetes/ingress.go index 2a6e1e335..139058386 100644 --- a/discovery/kubernetes/ingress.go +++ b/discovery/kubernetes/ingress.go @@ -55,26 +55,26 @@ func NewIngress(l log.Logger, inf cache.SharedInformer) *Ingress { return s } -func (e *Ingress) enqueue(obj interface{}) { +func (i *Ingress) enqueue(obj interface{}) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { return } - e.queue.Add(key) + i.queue.Add(key) } // Run implements the Discoverer interface. -func (s *Ingress) Run(ctx context.Context, ch chan<- []*targetgroup.Group) { - defer s.queue.ShutDown() +func (i *Ingress) Run(ctx context.Context, ch chan<- []*targetgroup.Group) { + defer i.queue.ShutDown() - if !cache.WaitForCacheSync(ctx.Done(), s.informer.HasSynced) { - level.Error(s.logger).Log("msg", "ingress informer unable to sync cache") + if !cache.WaitForCacheSync(ctx.Done(), i.informer.HasSynced) { + level.Error(i.logger).Log("msg", "ingress informer unable to sync cache") return } go func() { - for s.process(ctx, ch) { + for i.process(ctx, ch) { } }() @@ -82,12 +82,12 @@ func (s *Ingress) Run(ctx context.Context, ch chan<- []*targetgroup.Group) { <-ctx.Done() } -func (s *Ingress) process(ctx context.Context, ch chan<- []*targetgroup.Group) bool { - keyObj, quit := s.queue.Get() +func (i *Ingress) process(ctx context.Context, ch chan<- []*targetgroup.Group) bool { + keyObj, quit := i.queue.Get() if quit { return false } - defer s.queue.Done(keyObj) + defer i.queue.Done(keyObj) key := keyObj.(string) namespace, name, err := cache.SplitMetaNamespaceKey(key) @@ -95,20 +95,20 @@ func (s *Ingress) process(ctx context.Context, ch chan<- []*targetgroup.Group) b return true } - o, exists, err := s.store.GetByKey(key) + o, exists, err := i.store.GetByKey(key) if err != nil { return true } if !exists { - send(ctx, s.logger, RoleIngress, ch, &targetgroup.Group{Source: ingressSourceFromNamespaceAndName(namespace, name)}) + send(ctx, i.logger, RoleIngress, ch, &targetgroup.Group{Source: ingressSourceFromNamespaceAndName(namespace, name)}) return true } eps, err := convertToIngress(o) if err != nil { - level.Error(s.logger).Log("msg", "converting to Ingress object failed", "err", err) + level.Error(i.logger).Log("msg", "converting to Ingress object failed", "err", err) return true } - send(ctx, s.logger, RoleIngress, ch, s.buildIngress(eps)) + send(ctx, i.logger, RoleIngress, ch, i.buildIngress(eps)) return true } @@ -170,7 +170,7 @@ func pathsFromIngressRule(rv *v1beta1.IngressRuleValue) []string { return paths } -func (s *Ingress) buildIngress(ingress *v1beta1.Ingress) *targetgroup.Group { +func (i *Ingress) buildIngress(ingress *v1beta1.Ingress) *targetgroup.Group { tg := &targetgroup.Group{ Source: ingressSource(ingress), } diff --git a/discovery/kubernetes/node.go b/discovery/kubernetes/node.go index 2e1e0aaaf..07c09d3ae 100644 --- a/discovery/kubernetes/node.go +++ b/discovery/kubernetes/node.go @@ -61,13 +61,13 @@ func NewNode(l log.Logger, inf cache.SharedInformer) *Node { return n } -func (e *Node) enqueue(obj interface{}) { +func (n *Node) enqueue(obj interface{}) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { return } - e.queue.Add(key) + n.queue.Add(key) } // Run implements the Discoverer interface. diff --git a/discovery/kubernetes/pod.go b/discovery/kubernetes/pod.go index 986fcb8be..5b10f793d 100644 --- a/discovery/kubernetes/pod.go +++ b/discovery/kubernetes/pod.go @@ -69,13 +69,13 @@ func NewPod(l log.Logger, pods cache.SharedInformer) *Pod { return p } -func (e *Pod) enqueue(obj interface{}) { +func (p *Pod) enqueue(obj interface{}) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { return } - e.queue.Add(key) + p.queue.Add(key) } // Run implements the Discoverer interface. diff --git a/discovery/kubernetes/service.go b/discovery/kubernetes/service.go index ce04a936c..b3d225c05 100644 --- a/discovery/kubernetes/service.go +++ b/discovery/kubernetes/service.go @@ -61,13 +61,13 @@ func NewService(l log.Logger, inf cache.SharedInformer) *Service { return s } -func (e *Service) enqueue(obj interface{}) { +func (s *Service) enqueue(obj interface{}) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { return } - e.queue.Add(key) + s.queue.Add(key) } // Run implements the Discoverer interface. diff --git a/promql/bench_test.go b/promql/bench_test.go index b192df4f1..cd748f81a 100644 --- a/promql/bench_test.go +++ b/promql/bench_test.go @@ -60,7 +60,7 @@ func BenchmarkRangeQuery(b *testing.B) { // A day of data plus 10k steps. numIntervals := 8640 + 10000 - for s := 0; s < numIntervals; s += 1 { + for s := 0; s < numIntervals; s++ { a, err := storage.Appender() if err != nil { b.Fatal(err) diff --git a/promql/engine.go b/promql/engine.go index ad023016c..29b9618cc 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -613,7 +613,7 @@ func (ev *evaluator) Eval(expr Expr) (v Value, err error) { return ev.eval(expr), nil } -// Extra information and caches for evaluating a single node across steps. +// EvalNodeHelper stores extra information and caches for evaluating a single node across steps. type EvalNodeHelper struct { // Evaluation timestamp. ts int64 @@ -1531,19 +1531,19 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p valuesSquaredSum: s.V * s.V, groupCount: 1, } - input_vec_len := int64(len(vec)) - result_size := k - if k > input_vec_len { - result_size = input_vec_len + inputVecLen := int64(len(vec)) + resultSize := k + if k > inputVecLen { + resultSize = inputVecLen } if op == itemTopK || op == itemQuantile { - result[groupingKey].heap = make(vectorByValueHeap, 0, result_size) + result[groupingKey].heap = make(vectorByValueHeap, 0, resultSize) heap.Push(&result[groupingKey].heap, &Sample{ Point: Point{V: s.V}, Metric: s.Metric, }) } else if op == itemBottomK { - result[groupingKey].reverseHeap = make(vectorByReverseValueHeap, 0, result_size) + result[groupingKey].reverseHeap = make(vectorByReverseValueHeap, 0, resultSize) heap.Push(&result[groupingKey].reverseHeap, &Sample{ Point: Point{V: s.V}, Metric: s.Metric,