From 66ea16436aa51fcdd76de96ea1d66dbee44c4470 Mon Sep 17 00:00:00 2001 From: John Newbigin Date: Tue, 21 Apr 2026 14:04:46 +1000 Subject: [PATCH] chore: run lint in docker (#21292) --- Makefile | 4 ++++ pkg/logql/bench/k6_types.go | 2 +- pkg/logql/bench/query_registry.go | 8 ++++---- pkg/logql/bench/testcase.go | 9 +++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index f986e8469f..9456e8a7f0 100644 --- a/Makefile +++ b/Makefile @@ -347,6 +347,9 @@ LINT_FLAGS=--timeout=15m GOFLAGS="" endif lint: ## run linters +ifeq ($(BUILD_IN_CONTAINER),true) + $(run_in_container) +else go version golangci-lint version golangci-lint run -v $(LINT_FLAGS) @@ -363,6 +366,7 @@ lint: ## run linters faillint -paths \ "github.com/opentracing/opentracing-go,github.com/opentracing/opentracing-go/log,github.com/uber/jaeger-client-go,github.com/opentracing-contrib/go-stdlib/nethttp" \ ./... +endif ######## # Test # diff --git a/pkg/logql/bench/k6_types.go b/pkg/logql/bench/k6_types.go index fb33978a1e..7acacfc93c 100644 --- a/pkg/logql/bench/k6_types.go +++ b/pkg/logql/bench/k6_types.go @@ -35,7 +35,7 @@ func ConvertTestCaseToK6(tc TestCase, tenantID int, length time.Duration, buffer if tc.QueryDesc != "" { name = fmt.Sprintf("%s - %s", tc.Source, tc.QueryDesc) } - if kind == "log" { + if kind == kindLog { name = fmt.Sprintf("%s [%s]", name, directionLabel(tc.Direction)) } diff --git a/pkg/logql/bench/query_registry.go b/pkg/logql/bench/query_registry.go index 6db4875e87..ba5213c57f 100644 --- a/pkg/logql/bench/query_registry.go +++ b/pkg/logql/bench/query_registry.go @@ -204,12 +204,12 @@ func (r *QueryRegistry) loadFile(filePath string, suite Suite, fileName string) q.Source = fmt.Sprintf("%s/%s:%d", suite, fileName, lineNum) // Default directions to "both" for log queries - if q.Directions == "" && q.Kind == "log" { + if q.Directions == "" && q.Kind == kindLog { q.Directions = DirectionBoth } - if q.Kind == "" || (q.Kind != "metric" && q.Kind != "log") { - q.Kind = "log" + if q.Kind == "" || (q.Kind != kindMetric && q.Kind != kindLog) { + q.Kind = kindLog } // Validate time range @@ -325,7 +325,7 @@ func (r *QueryRegistry) ExpandQuery(def QueryDefinition, resolver VariableResolv // Create test cases based on query kind and directions var cases []TestCase - if def.Kind == "metric" { + if def.Kind == kindMetric { // Metric queries only run in forward direction tc := TestCase{ Query: resolvedQuery, diff --git a/pkg/logql/bench/testcase.go b/pkg/logql/bench/testcase.go index a6326e1fea..92ff48d04d 100644 --- a/pkg/logql/bench/testcase.go +++ b/pkg/logql/bench/testcase.go @@ -10,6 +10,11 @@ import ( "github.com/grafana/loki/v3/pkg/logql/syntax" ) +const ( + kindLog = "log" + kindMetric = "metric" +) + // TestCase represents a LogQL test case for benchmarking and testing type TestCase struct { Query string @@ -53,9 +58,9 @@ func (c TestCase) Kind() string { return "invalid" } if _, ok := expr.(syntax.SampleExpr); ok { - return "metric" + return kindMetric } - return "log" + return kindLog } // Description returns a detailed description of the test case including time range