From 91220c41f27f31d24207f6638a0a8a19fb3db50e Mon Sep 17 00:00:00 2001 From: yeya24 Date: Thu, 29 Apr 2021 11:32:16 -0400 Subject: [PATCH] fix lint Signed-off-by: yeya24 --- pkg/exemplars/proxy.go | 13 +++++-------- pkg/exemplars/proxy_test.go | 8 ++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/exemplars/proxy.go b/pkg/exemplars/proxy.go index 96e1ef87de1..5c89ef9c9e9 100644 --- a/pkg/exemplars/proxy.go +++ b/pkg/exemplars/proxy.go @@ -61,10 +61,7 @@ func (s *Proxy) Exemplars(req *exemplarspb.ExemplarsRequest, srv exemplarspb.Exe newSelectors := make([][]*labels.Matcher, 0, len(selectors)) for _, matchers := range selectors { - matched, newMatchers, err := matchesExternalLabels(matchers, s.selectorLabels) - if err != nil { - return err - } + matched, newMatchers:= matchesExternalLabels(matchers, s.selectorLabels) if matched { newSelectors = append(newSelectors, newMatchers) } @@ -211,9 +208,9 @@ func (stream *exemplarsStream) receive(ctx context.Context) error { // matchesExternalLabels returns false if given matchers are not matching external labels. // If true, matchesExternalLabels also returns Prometheus matchers without those matching external labels. -func matchesExternalLabels(ms []*labels.Matcher, externalLabels labels.Labels) (bool, []*labels.Matcher, error) { +func matchesExternalLabels(ms []*labels.Matcher, externalLabels labels.Labels) (bool, []*labels.Matcher) { if len(externalLabels) == 0 { - return true, ms, nil + return true, ms } var newMatchers []*labels.Matcher @@ -230,8 +227,8 @@ func matchesExternalLabels(ms []*labels.Matcher, externalLabels labels.Labels) ( if !tm.Matches(extValue) { // External label does not match. This should not happen - it should be filtered out on query node, // but let's do that anyway here. - return false, nil, nil + return false, nil } } - return true, newMatchers, nil + return true, newMatchers } diff --git a/pkg/exemplars/proxy_test.go b/pkg/exemplars/proxy_test.go index d787d17c2d1..cb493c22bdf 100644 --- a/pkg/exemplars/proxy_test.go +++ b/pkg/exemplars/proxy_test.go @@ -218,7 +218,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -227,7 +227,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 2}}, }), }, @@ -237,11 +237,11 @@ func TestProxy(t *testing.T) { server: &testExemplarServer{}, wantResponses: []*exemplarspb.ExemplarsResponse{ exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 2}}, }), },