Skip to content

Commit 3b8b996

Browse files
authored
[Chore] Fix lint warnings from #47247 (#47648)
1 parent 86ff583 commit 3b8b996

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

filebeat/input/filestream/input.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ func (inp *filestream) readFromSource(
717717
//nolint:gosec // message.Bytes is always positive
718718
metrics.BytesProcessed.Add(uint64(message.Bytes))
719719
if isGZIP {
720+
//nolint:gosec // message.Bytes is always positive, no risk of overflow here
720721
metrics.BytesGZIPProcessed.Add(uint64(message.Bytes))
721722
}
722723

@@ -725,8 +726,10 @@ func (inp *filestream) readFromSource(
725726
_ = mapstr.AddTags(message.Fields, []string{"take_over"})
726727
}
727728

728-
if isGZIP && message.Private == io.EOF {
729-
s.EOF = true
729+
if isGZIP {
730+
if err, ok := (message.Private).(error); ok && errors.Is(err, io.EOF) {
731+
s.EOF = true
732+
}
730733
}
731734
if err := p.Publish(message.ToEvent(), s); err != nil {
732735
metrics.ProcessingErrors.Inc()

filebeat/input/filestream/internal/input-logfile/input.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type managedInput struct {
3333
// id is the input ID, it is defined by setting 'id'
3434
// in the input configuration
3535
id string
36-
metricsID string
3736
manager *InputManager
3837
ackCH *updateChan
3938
sourceIdentifier *SourceIdentifier
@@ -104,10 +103,10 @@ func (inp *managedInput) Run(
104103
}
105104

106105
func newInputACKHandler(ch *updateChan) beat.EventListener {
107-
return acker.EventPrivateReporter(func(acked int, private []interface{}) {
106+
return acker.EventPrivateReporter(func(acked int, private []any) {
108107
var n uint
109108
var last int
110-
for i := 0; i < len(private); i++ {
109+
for i := range private {
111110
current := private[i]
112111
if current == nil {
113112
continue
@@ -125,6 +124,7 @@ func newInputACKHandler(ch *updateChan) beat.EventListener {
125124
return
126125
}
127126

127+
//nolint:errcheck // We know it is alwys the correct type
128128
op := private[last].(*updateOp)
129129
ch.Send(scheduledUpdate{op: op, n: n})
130130
})

filebeat/input/filestream/internal/input-logfile/store.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func (s *sourceStore) UpdateIdentifiers(getNewID func(v Value) (string, any)) {
285285
// - 3. Finally, synchronously remove it from the disk store.
286286
s.store.UpdateTTL(res, 0)
287287
delete(s.store.ephemeralStore.table, res.key)
288-
s.store.persistentStore.Remove(res.key)
288+
_ = s.store.persistentStore.Remove(res.key)
289289
s.store.log.Infof("migrated entry in registry from '%s' to '%s'. Cursor: %v", key, newKey, r.cursor)
290290
}
291291

@@ -341,7 +341,7 @@ func (s *sourceStore) TakeOver(fn func(Value) (string, any)) {
341341
// a Filestream input
342342
fromLogInput := map[string]logInputState{}
343343
if len(s.identifiersToTakeOver) == 0 {
344-
s.store.persistentStore.Each(func(key string, value statestore.ValueDecoder) (bool, error) {
344+
_ = s.store.persistentStore.Each(func(key string, value statestore.ValueDecoder) (bool, error) {
345345
if strings.HasPrefix(key, "filebeat::logs::") {
346346
m := mapstr.M{}
347347
if err := value.Decode(&m); err != nil {
@@ -450,7 +450,7 @@ func (s *sourceStore) TakeOver(fn func(Value) (string, any)) {
450450
// - 3. Finally, synchronously remove it from the disk store.
451451
s.store.UpdateTTL(res, 0)
452452
delete(s.store.ephemeralStore.table, res.key)
453-
s.store.persistentStore.Remove(res.key)
453+
_ = s.store.persistentStore.Remove(res.key)
454454
s.store.log.Infof("migrated entry in registry from '%s' to '%s'. Cursor: %v", k, newKey, r.cursor)
455455
}
456456

@@ -484,7 +484,7 @@ func (s *sourceStore) TakeOver(fn func(Value) (string, any)) {
484484
// it read when Filebeat was starting, thus "overriding" this delete.
485485
// We keep it here because when we remove the Log input we will ensure
486486
// the entry is actually remove from the disk store.
487-
s.store.persistentStore.Remove(k)
487+
_ = s.store.persistentStore.Remove(k)
488488
res.Release()
489489
s.store.log.Infof("migrated entry in registry from '%s' to '%s'. Cursor: %v", k, newKey, res.cursor)
490490
}
@@ -507,7 +507,7 @@ func logInputStateFromMapM(m mapstr.M) (logInputState, error) {
507507

508508
// typeconf.Convert kept failing with an "unsupported" error because
509509
// FileStateOS was present, we don't need it, so just delete it.
510-
m.Delete("FileStateOS") //nolint:errcheck // The key is always there
510+
m.Delete("FileStateOS")
511511
if err := typeconv.Convert(&state, m); err != nil {
512512
return logInputState{}, fmt.Errorf("cannot convert Log input state: %w", err)
513513
}

filebeat/input/filestream/prospector_creator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestCreateProspector(t *testing.T) {
4949
IgnoreInactive: ignoreInactiveSettings[test.ignore_inactive_since],
5050
}
5151
p, _ := newProspector(c, logp.NewNopLogger(), mustSourceIdentifier("foo-id"))
52-
fileProspector := p.(*fileProspector)
52+
fileProspector := p.(*fileProspector) //nolint:errcheck // we know the type
5353
assert.Equal(t, fileProspector.ignoreInactiveSince, ignoreInactiveSettings[test.ignore_inactive_since])
5454
})
5555
}

filebeat/input/filestream/prospector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestProspector_InitUpdateIdentifiers(t *testing.T) {
107107
}
108108
defer f.Close()
109109
tmpFileName := f.Name()
110-
fi, err := f.Stat() //nolint:typecheck // It is used on L151
110+
fi, err := f.Stat()
111111
if err != nil {
112112
t.Fatalf("cannot stat test file: %v", err)
113113
}

0 commit comments

Comments
 (0)