From 3f2a3425467db7c54645ed6c2cce7654a50ed51b Mon Sep 17 00:00:00 2001 From: Khurram Baig Date: Fri, 17 Jan 2025 11:43:37 +0530 Subject: [PATCH] Migrate to GitHubAction for GolangCI Lint This fixes the issues related to GolangCI Lint. --- pkg/api/server/cel2sql/interpreter.go | 4 ++-- pkg/api/server/config/config.go | 2 +- pkg/api/server/db/pagination/pagination.go | 6 +++--- pkg/api/server/v1alpha2/log/s3.go | 5 ++--- pkg/api/server/v1alpha2/ordering_test.go | 4 ++-- pkg/api/server/v1alpha2/plugin/plugin_logs.go | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/api/server/cel2sql/interpreter.go b/pkg/api/server/cel2sql/interpreter.go index c0740671f..52dd7d1a1 100644 --- a/pkg/api/server/cel2sql/interpreter.go +++ b/pkg/api/server/cel2sql/interpreter.go @@ -89,9 +89,9 @@ func (i *interpreter) interpretExpr(expr *exprpb.Expr) error { func (i *interpreter) unsupportedExprError(id int64, name string) error { sourceInfo := i.checkedExpr.SourceInfo column := sourceInfo.Positions[id] - var line int32 + var line int for i, offset := range sourceInfo.LineOffsets { - line = int32(i) + 1 + line = i + 1 if offset > column { break } diff --git a/pkg/api/server/config/config.go b/pkg/api/server/config/config.go index c8d0d95f5..52ff1c31f 100644 --- a/pkg/api/server/config/config.go +++ b/pkg/api/server/config/config.go @@ -61,7 +61,7 @@ type Config struct { LOGGING_PLUGIN_CA_CERT string `mapstructure:"LOGGING_PLUGIN_CA_CERT"` LOGGING_PLUGIN_QUERY_LIMIT uint `mapstructure:"LOGGING_PLUGIN_QUERY_LIMIT"` LOGGING_PLUGIN_TLS_VERIFICATION_DISABLE bool `mapstructure:"LOGGING_PLUGIN_TLS_VERIFICATION_DISABLE"` - LOGGING_PLUGIN_FORWARDER_DELAY_DURATION uint `mapstructure:"LOGGING_PLUGIN_FORWARDER_DELAY_DURATION"` + LOGGING_PLUGIN_FORWARDER_DELAY_DURATION int64 `mapstructure:"LOGGING_PLUGIN_FORWARDER_DELAY_DURATION"` LOGGING_PLUGIN_QUERY_PARAMS string `mapstructure:"LOGGING_PLUGIN_QUERY_PARAMS"` } diff --git a/pkg/api/server/db/pagination/pagination.go b/pkg/api/server/db/pagination/pagination.go index f6f61b418..f5364a080 100644 --- a/pkg/api/server/db/pagination/pagination.go +++ b/pkg/api/server/db/pagination/pagination.go @@ -71,11 +71,11 @@ type Batcher struct { } // NewBatcher creates a new batcher for the given requested page size. -func NewBatcher(want, min, max int) *Batcher { +func NewBatcher(want, mini, maxi int) *Batcher { return &Batcher{ want: want, - min: min, - max: max, + min: mini, + max: maxi, ratio: 1, } } diff --git a/pkg/api/server/v1alpha2/log/s3.go b/pkg/api/server/v1alpha2/log/s3.go index d592908e4..fd4aa619e 100644 --- a/pkg/api/server/v1alpha2/log/s3.go +++ b/pkg/api/server/v1alpha2/log/s3.go @@ -8,7 +8,6 @@ import ( v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "context" - "fmt" "io" "github.com/aws/aws-sdk-go-v2/aws" @@ -141,7 +140,7 @@ func (s3s *s3Stream) WriteTo(w io.Writer) (n int64, err error) { Key: &s3s.key, }) if err != nil { - return 0, fmt.Errorf(err.Error()) + return 0, err } defer outPut.Body.Close() @@ -149,7 +148,7 @@ func (s3s *s3Stream) WriteTo(w io.Writer) (n int64, err error) { reader := bufio.NewReaderSize(outPut.Body, s3s.size) n, err = reader.WriteTo(w) if err != nil { - return 0, fmt.Errorf(err.Error()) + return 0, err } return } diff --git a/pkg/api/server/v1alpha2/ordering_test.go b/pkg/api/server/v1alpha2/ordering_test.go index a037db886..b9e63ea1f 100644 --- a/pkg/api/server/v1alpha2/ordering_test.go +++ b/pkg/api/server/v1alpha2/ordering_test.go @@ -25,7 +25,7 @@ func TestOrderBy(t *testing.T) { t.Errorf("unexpected error: %v", err) } if ob != tc.out { - t.Errorf(diff.PrintWantGot(cmp.Diff(tc.out, ob))) + t.Error(diff.PrintWantGot(cmp.Diff(tc.out, ob))) } } } @@ -70,7 +70,7 @@ func TestNormalizeOrderByField(t *testing.T) { t.Errorf("unexpected error: %v", err) } if n != tc.out { - t.Errorf(diff.PrintWantGot(cmp.Diff(tc.out, n))) + t.Error(diff.PrintWantGot(cmp.Diff(tc.out, n))) } } } diff --git a/pkg/api/server/v1alpha2/plugin/plugin_logs.go b/pkg/api/server/v1alpha2/plugin/plugin_logs.go index dd544ae9a..c3c0799b2 100644 --- a/pkg/api/server/v1alpha2/plugin/plugin_logs.go +++ b/pkg/api/server/v1alpha2/plugin/plugin_logs.go @@ -172,7 +172,7 @@ func getLokiLogs(s *LogServer, writer io.Writer, parent string, rec *db.Record) parameters.Add("query", `{ `+s.staticLabels+s.config.LOGGING_PLUGIN_NAMESPACE_KEY+`="`+parent+`" }|json uid="`+uidKey+`", message="message" |uid="`+rec.Name+`"| line_format "{{.message}}"`) parameters.Add("end", endTime) parameters.Add("start", startTime) - parameters.Add("limit", strconv.Itoa(int(s.queryLimit))) + parameters.Add("limit", strconv.FormatUint(uint64(s.queryLimit), 10)) URL.RawQuery = parameters.Encode() s.logger.Debugf("loki request url:%s", URL.String())