Skip to content

Commit 37a8fde

Browse files
committed
Fixing CI deprecations
Replacing deprecated golint with revive (golangci/golangci-lint#1965) Removing interfacer (golangci/golangci-lint#1755) Signed-off-by: Danny Kopping <[email protected]>
1 parent 12253ec commit 37a8fde

File tree

20 files changed

+25
-41
lines changed

20 files changed

+25
-41
lines changed

.golangci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ linters:
5555
- goconst
5656
- gofmt
5757
- goimports
58-
- golint
58+
- revive
5959
- gosimple
6060
- ineffassign
6161
- megacheck
@@ -66,7 +66,6 @@ linters:
6666
- varcheck
6767
- govet
6868
- unused # new from here.
69-
- interfacer
7069
- typecheck
7170

7271
issues:

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ publish: dist
263263
# Lint #
264264
########
265265

266+
# To run this efficiently on your workstation, use:
267+
# docker run --rm --tty -i -v $(pwd)/.cache:/go/cache -v $(pwd)/.pkg:/go/pkg -v $(pwd):/src/loki grafana/loki-build-image:0.17.0 lint
266268
lint:
267269
GO111MODULE=on GOGC=10 golangci-lint run -v $(GOLANGCI_ARG)
268270
faillint -paths "sync/atomic=go.uber.org/atomic" ./...

clients/cmd/docker-driver/loki.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func New(logCtx logger.Info, logger log.Logger) (logger.Logger, error) {
4444
return nil, err
4545
}
4646
var handler api.EntryHandler = c
47-
var stop func() = func() {}
47+
var stop = func() {}
4848
if len(cfg.pipeline.PipelineStages) != 0 {
4949
pipeline, err := stages.NewPipeline(logger, cfg.pipeline.PipelineStages, &jobName, prometheus.DefaultRegisterer)
5050
if err != nil {

clients/pkg/promtail/targets/file/filetarget.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (cfg *Config) RegisterFlags(flags *flag.FlagSet) {
4444
}
4545

4646
// FileTarget describes a particular set of logs.
47-
// nolint:golint
47+
// nolint:revive
4848
type FileTarget struct {
4949
metrics *Metrics
5050
logger log.Logger

clients/pkg/promtail/targets/file/filetargetmanager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
)
3434

3535
// FileTargetManager manages a set of targets.
36-
// nolint:golint
36+
// nolint:revive
3737
type FileTargetManager struct {
3838
log log.Logger
3939
quit context.CancelFunc

clients/pkg/promtail/targets/gcplog/formatter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func init() {
3131
// LogEntry that will be written to the pubsub topic.
3232
// According to the following spec.
3333
// https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
34-
// nolint: golint
34+
// nolint:revive
3535
type GCPLogEntry struct {
3636
LogName string `json:"logName"`
3737
Resource struct {

clients/pkg/promtail/targets/gcplog/target.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
// GcplogTarget represents the target specific to GCP project.
1919
// It collects logs from GCP and push it to Loki.
20-
// nolint:golint
20+
// nolint:revive
2121
type GcplogTarget struct {
2222
metrics *Metrics
2323
logger log.Logger
@@ -41,7 +41,7 @@ type GcplogTarget struct {
4141
// and push it Loki via given `api.EntryHandler.`
4242
// It starts the `run` loop to consume log entries that can be
4343
// stopped via `target.Stop()`
44-
// nolint:golint,govet
44+
// nolint:revive,govet
4545
func NewGcplogTarget(
4646
metrics *Metrics,
4747
logger log.Logger,
@@ -66,7 +66,7 @@ func NewGcplogTarget(
6666
return target, nil
6767
}
6868

69-
// nolint: golint
69+
// nolint:revive
7070
func newGcplogTarget(
7171
metrics *Metrics,
7272
logger log.Logger,

clients/pkg/promtail/targets/gcplog/targetmanager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/grafana/loki/clients/pkg/promtail/targets/target"
1313
)
1414

15-
// nolint: golint
15+
// nolint:revive
1616
type GcplogTargetManager struct {
1717
logger log.Logger
1818
targets map[string]*GcplogTarget

clients/pkg/promtail/targets/journal/journaltargetmanager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// JournalTargetManager manages a series of JournalTargets.
18-
// nolint:golint
18+
// nolint:revive
1919
type JournalTargetManager struct{}
2020

2121
// NewJournalTargetManager returns nil as JournalTargets are not supported

clients/pkg/promtail/targets/stdin/stdin_target_manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type Shutdownable interface {
5252
Shutdown()
5353
}
5454

55-
// nolint:golint
55+
// nolint:revive
5656
type StdinTargetManager struct {
5757
*readerTarget
5858
app Shutdownable

clients/pkg/promtail/targets/syslog/syslogtarget.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
)
3434

3535
// SyslogTarget listens to syslog messages.
36-
// nolint:golint
36+
// nolint:revive
3737
type SyslogTarget struct {
3838
metrics *Metrics
3939
logger log.Logger

clients/pkg/promtail/targets/syslog/syslogtargetmanager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
// SyslogTargetManager manages a series of SyslogTargets.
15-
// nolint:golint
15+
// nolint:revive
1616
type SyslogTargetManager struct {
1717
logger log.Logger
1818
targets map[string]*SyslogTarget

clients/pkg/promtail/targets/target/target.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66

77
// TargetType is the type of target
8-
// nolint:golint
8+
// nolint:revive
99
type TargetType string
1010

1111
const (

pkg/querier/queryrange/split_by_interval.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (h *splitByInterval) Process(
102102
}
103103

104104
// don't spawn unnecessary goroutines
105-
var p int = parallelism
105+
var p = parallelism
106106
if len(input) < parallelism {
107107
p = len(input)
108108
}

pkg/storage/chunk/aws/dynamodb_table_client.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (d dynamoTableClient) CreateTable(ctx context.Context, desc chunk.TableDesc
199199
}
200200

201201
func (d dynamoTableClient) DeleteTable(ctx context.Context, name string) error {
202-
if err := d.backoffAndRetry(ctx, func(ctx context.Context) error {
202+
return d.backoffAndRetry(ctx, func(ctx context.Context) error {
203203
return instrument.CollectedRequest(ctx, "DynamoDB.DeleteTable", d.metrics.dynamoRequestDuration, instrument.ErrorCode, func(ctx context.Context) error {
204204
input := &dynamodb.DeleteTableInput{TableName: aws.String(name)}
205205
_, err := d.DynamoDB.DeleteTableWithContext(ctx, input)
@@ -209,11 +209,7 @@ func (d dynamoTableClient) DeleteTable(ctx context.Context, name string) error {
209209

210210
return nil
211211
})
212-
}); err != nil {
213-
return err
214-
}
215-
216-
return nil
212+
})
217213
}
218214

219215
func (d dynamoTableClient) DescribeTable(ctx context.Context, name string) (desc chunk.TableDesc, isActive bool, err error) {

pkg/storage/chunk/chunk_store.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ func (cfg *StoreConfig) Validate(logger log.Logger) error {
8282
if err := cfg.ChunkCacheConfig.Validate(); err != nil {
8383
return err
8484
}
85-
if err := cfg.WriteDedupeCacheConfig.Validate(); err != nil {
86-
return err
87-
}
88-
return nil
85+
return cfg.WriteDedupeCacheConfig.Validate()
8986
}
9087

9188
type baseStore struct {

pkg/storage/chunk/gcp/gcs_object_client.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ func (s *GCSObjectClient) PutObject(ctx context.Context, objectKey string, objec
112112
_ = writer.Close()
113113
return err
114114
}
115-
if err := writer.Close(); err != nil {
116-
return err
117-
}
118-
119-
return nil
115+
return writer.Close()
120116
}
121117

122118
// List implements chunk.ObjectClient.

pkg/storage/chunk/purger/purger.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func (p *Purger) executePlan(userID, requestID string, planNo int, logger log.Lo
357357
return err
358358
}
359359

360-
var partiallyDeletedInterval *model.Interval = nil
360+
var partiallyDeletedInterval *model.Interval
361361
if chunkDetails.PartiallyDeletedInterval != nil {
362362
partiallyDeletedInterval = &model.Interval{
363363
Start: model.Time(chunkDetails.PartiallyDeletedInterval.StartTimestampMs),

pkg/storage/stores/shipper/compactor/retention/iterator_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ func Test_SeriesCleaner(t *testing.T) {
104104
if err := cleaner.Cleanup(entryFromChunk(c2).UserID, c2.Metric); err != nil {
105105
return err
106106
}
107-
if err := cleaner.Cleanup(entryFromChunk(c1).UserID, c1.Metric); err != nil {
108-
return err
109-
}
110-
return nil
107+
return cleaner.Cleanup(entryFromChunk(c1).UserID, c1.Metric)
111108
})
112109
require.NoError(t, err)
113110

pkg/storage/stores/shipper/compactor/retention/marker.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (r *markerProcessor) processPath(path string, deleteFunc func(ctx context.C
303303
}
304304
}()
305305
}
306-
if err := dbView.View(func(tx *bbolt.Tx) error {
306+
return dbView.View(func(tx *bbolt.Tx) error {
307307
b := tx.Bucket(chunkBucket)
308308
if b == nil {
309309
return nil
@@ -323,10 +323,7 @@ func (r *markerProcessor) processPath(path string, deleteFunc func(ctx context.C
323323

324324
}
325325
return nil
326-
}); err != nil {
327-
return err
328-
}
329-
return nil
326+
})
330327
}
331328

332329
func processKey(ctx context.Context, key *keyPair, db *bbolt.DB, deleteFunc func(ctx context.Context, chunkId []byte) error) error {

0 commit comments

Comments
 (0)