chore(linters): Bump golangci-lint to v1.59.1 (#15478)
This commit is contained in:
parent
05ba4951ee
commit
28f6396348
|
|
@ -106,7 +106,7 @@ jobs:
|
||||||
- run: 'make check-deps'
|
- run: 'make check-deps'
|
||||||
- run:
|
- run:
|
||||||
name: "Install golangci-lint"
|
name: "Install golangci-lint"
|
||||||
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
|
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
|
||||||
- run:
|
- run:
|
||||||
name: "golangci-lint/Linux"
|
name: "golangci-lint/Linux"
|
||||||
command: GOGC=80 GOMEMLIMIT=6656MiB /go/bin/golangci-lint run --verbose
|
command: GOGC=80 GOMEMLIMIT=6656MiB /go/bin/golangci-lint run --verbose
|
||||||
|
|
@ -117,7 +117,7 @@ jobs:
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
- run:
|
- run:
|
||||||
name: "Install golangci-lint"
|
name: "Install golangci-lint"
|
||||||
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
|
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
|
||||||
- run:
|
- run:
|
||||||
name: "golangci-lint/macOS"
|
name: "golangci-lint/macOS"
|
||||||
command: GOGC=80 GOMEMLIMIT=6656MiB GOOS=darwin /go/bin/golangci-lint run --verbose --timeout=30m
|
command: GOGC=80 GOMEMLIMIT=6656MiB GOOS=darwin /go/bin/golangci-lint run --verbose --timeout=30m
|
||||||
|
|
@ -129,7 +129,7 @@ jobs:
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
- run:
|
- run:
|
||||||
name: "Install golangci-lint"
|
name: "Install golangci-lint"
|
||||||
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
|
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
|
||||||
- run:
|
- run:
|
||||||
name: "golangci-lint/Windows"
|
name: "golangci-lint/Windows"
|
||||||
command: GOGC=80 GOMEMLIMIT=6656MiB GOOS=windows /go/bin/golangci-lint run --verbose --timeout=30m
|
command: GOGC=80 GOMEMLIMIT=6656MiB GOOS=windows /go/bin/golangci-lint run --verbose --timeout=30m
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ linters-settings:
|
||||||
# Enable checkers by name
|
# Enable checkers by name
|
||||||
# (in addition to default
|
# (in addition to default
|
||||||
# blank-import, bool-compare, compares, empty, error-is-as, error-nil, expected-actual, go-require, float-compare,
|
# blank-import, bool-compare, compares, empty, error-is-as, error-nil, expected-actual, go-require, float-compare,
|
||||||
# len, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert
|
# len, negative-positive, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert
|
||||||
# ).
|
# ).
|
||||||
enable:
|
enable:
|
||||||
- bool-compare
|
- bool-compare
|
||||||
|
|
@ -388,7 +388,19 @@ issues:
|
||||||
# output configuration options
|
# output configuration options
|
||||||
output:
|
output:
|
||||||
# The formats used to render issues.
|
# The formats used to render issues.
|
||||||
# Format: `colored-line-number`, `line-number`, `json`, `colored-tab`, `tab`, `checkstyle`, `code-climate`, `junit-xml`, `github-actions`, `teamcity`
|
# Formats:
|
||||||
|
# - `colored-line-number`
|
||||||
|
# - `line-number`
|
||||||
|
# - `json`
|
||||||
|
# - `colored-tab`
|
||||||
|
# - `tab`
|
||||||
|
# - `html`
|
||||||
|
# - `checkstyle`
|
||||||
|
# - `code-climate`
|
||||||
|
# - `junit-xml`
|
||||||
|
# - `github-actions`
|
||||||
|
# - `teamcity`
|
||||||
|
# - `sarif`
|
||||||
# Output path can be either `stdout`, `stderr` or path to the file to write to.
|
# Output path can be either `stdout`, `stderr` or path to the file to write to.
|
||||||
#
|
#
|
||||||
# For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma.
|
# For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma.
|
||||||
|
|
|
||||||
2
Makefile
2
Makefile
|
|
@ -180,7 +180,7 @@ vet:
|
||||||
.PHONY: lint-install
|
.PHONY: lint-install
|
||||||
lint-install:
|
lint-install:
|
||||||
@echo "Installing golangci-lint"
|
@echo "Installing golangci-lint"
|
||||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
|
||||||
|
|
||||||
@echo "Installing markdownlint"
|
@echo "Installing markdownlint"
|
||||||
npm install -g markdownlint-cli
|
npm install -g markdownlint-cli
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,8 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
return c.aggregateMetrics(acc, results)
|
c.aggregateMetrics(acc, results)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatch) initializeCloudWatch() error {
|
func (c *CloudWatch) initializeCloudWatch() error {
|
||||||
|
|
@ -455,14 +456,8 @@ func (c *CloudWatch) gatherMetrics(
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatch) aggregateMetrics(
|
func (c *CloudWatch) aggregateMetrics(acc telegraf.Accumulator, metricDataResults map[string][]types.MetricDataResult) {
|
||||||
acc telegraf.Accumulator,
|
grouper := internalMetric.NewSeriesGrouper()
|
||||||
metricDataResults map[string][]types.MetricDataResult,
|
|
||||||
) error {
|
|
||||||
var (
|
|
||||||
grouper = internalMetric.NewSeriesGrouper()
|
|
||||||
)
|
|
||||||
|
|
||||||
for namespace, results := range metricDataResults {
|
for namespace, results := range metricDataResults {
|
||||||
namespace = sanitizeMeasurement(namespace)
|
namespace = sanitizeMeasurement(namespace)
|
||||||
|
|
||||||
|
|
@ -497,8 +492,6 @@ func (c *CloudWatch) aggregateMetrics(
|
||||||
for _, metric := range grouper.Metrics() {
|
for _, metric := range grouper.Metrics() {
|
||||||
acc.AddMetric(metric)
|
acc.AddMetric(metric)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
||||||
|
|
@ -117,10 +117,11 @@ func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype stri
|
||||||
host, _, _ = net.SplitHostPort(addr)
|
host, _, _ = net.SplitHostPort(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return gatherStats(&buf, acc, host, qtype)
|
gatherStats(&buf, acc, host, qtype)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype string) error {
|
func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype string) {
|
||||||
lines := strings.Split(buf.String(), "\n")
|
lines := strings.Split(buf.String(), "\n")
|
||||||
head := strings.Split(lines[0], "\t")
|
head := strings.Split(lines[0], "\t")
|
||||||
vals := lines[1:]
|
vals := lines[1:]
|
||||||
|
|
@ -154,8 +155,6 @@ func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype
|
||||||
|
|
||||||
acc.AddFields("dovecot", fields, tags)
|
acc.AddFields("dovecot", fields, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitSec(tm string) (sec int64, msec int64) {
|
func splitSec(tm string) (sec int64, msec int64) {
|
||||||
|
|
|
||||||
|
|
@ -94,27 +94,21 @@ func TestDovecotIntegration(t *testing.T) {
|
||||||
tags = map[string]string{"server": "dovecot.test", "type": "global"}
|
tags = map[string]string{"server": "dovecot.test", "type": "global"}
|
||||||
buf := bytes.NewBufferString(sampleGlobal)
|
buf := bytes.NewBufferString(sampleGlobal)
|
||||||
|
|
||||||
err = gatherStats(buf, &acc, "dovecot.test", "global")
|
gatherStats(buf, &acc, "dovecot.test", "global")
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
||||||
|
|
||||||
// Test type=domain
|
// Test type=domain
|
||||||
tags = map[string]string{"server": "dovecot.test", "type": "domain", "domain": "domain.test"}
|
tags = map[string]string{"server": "dovecot.test", "type": "domain", "domain": "domain.test"}
|
||||||
buf = bytes.NewBufferString(sampleDomain)
|
buf = bytes.NewBufferString(sampleDomain)
|
||||||
|
|
||||||
err = gatherStats(buf, &acc, "dovecot.test", "domain")
|
gatherStats(buf, &acc, "dovecot.test", "domain")
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
||||||
|
|
||||||
// Test type=ip
|
// Test type=ip
|
||||||
tags = map[string]string{"server": "dovecot.test", "type": "ip", "ip": "192.168.0.100"}
|
tags = map[string]string{"server": "dovecot.test", "type": "ip", "ip": "192.168.0.100"}
|
||||||
buf = bytes.NewBufferString(sampleIP)
|
buf = bytes.NewBufferString(sampleIP)
|
||||||
|
|
||||||
err = gatherStats(buf, &acc, "dovecot.test", "ip")
|
gatherStats(buf, &acc, "dovecot.test", "ip")
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
||||||
|
|
||||||
// Test type=user
|
// Test type=user
|
||||||
|
|
@ -146,9 +140,7 @@ func TestDovecotIntegration(t *testing.T) {
|
||||||
tags = map[string]string{"server": "dovecot.test", "type": "user", "user": "user.1@domain.test"}
|
tags = map[string]string{"server": "dovecot.test", "type": "user", "user": "user.1@domain.test"}
|
||||||
buf = bytes.NewBufferString(sampleUser)
|
buf = bytes.NewBufferString(sampleUser)
|
||||||
|
|
||||||
err = gatherStats(buf, &acc, "dovecot.test", "user")
|
gatherStats(buf, &acc, "dovecot.test", "user")
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ func (h *HTTPResponse) httpGather(u string) (map[string]interface{}, map[string]
|
||||||
return fields, tags, nil
|
return fields, tags, nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
h.setBodyReadError("Failed to read body of HTTP Response : "+err.Error(), bodyBytes, fields, tags)
|
h.setBodyReadError("Failed to read body of HTTP Response : "+err.Error(), bodyBytes, fields, tags)
|
||||||
return fields, tags, nil //nolint:nilerr // error is handled properly
|
return fields, tags, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the body of the response if expected
|
// Add the body of the response if expected
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,9 @@ func (l *LogParserPlugin) Gather(_ telegraf.Accumulator) error {
|
||||||
defer l.Unlock()
|
defer l.Unlock()
|
||||||
|
|
||||||
// always start from the beginning of files that appear while we're running
|
// always start from the beginning of files that appear while we're running
|
||||||
return l.tailNewfiles(true)
|
l.tailNewFiles(true)
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start kicks off collection of stats for the plugin
|
// Start kicks off collection of stats for the plugin
|
||||||
|
|
@ -134,7 +136,7 @@ func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
|
||||||
l.wg.Add(1)
|
l.wg.Add(1)
|
||||||
go l.parser()
|
go l.parser()
|
||||||
|
|
||||||
err = l.tailNewfiles(l.FromBeginning)
|
l.tailNewFiles(l.FromBeginning)
|
||||||
|
|
||||||
// clear offsets
|
// clear offsets
|
||||||
l.offsets = make(map[string]int64)
|
l.offsets = make(map[string]int64)
|
||||||
|
|
@ -143,12 +145,12 @@ func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
|
||||||
offsets = make(map[string]int64)
|
offsets = make(map[string]int64)
|
||||||
offsetsMutex.Unlock()
|
offsetsMutex.Unlock()
|
||||||
|
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the globs against files on disk, and start tailing any new files.
|
// check the globs against files on disk, and start tailing any new files.
|
||||||
// Assumes l's lock is held!
|
// Assumes l's lock is held!
|
||||||
func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
|
func (l *LogParserPlugin) tailNewFiles(fromBeginning bool) {
|
||||||
var poll bool
|
var poll bool
|
||||||
if l.WatchMethod == "poll" {
|
if l.WatchMethod == "poll" {
|
||||||
poll = true
|
poll = true
|
||||||
|
|
@ -207,8 +209,6 @@ func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
|
||||||
l.tailers[file] = tailer
|
l.tailers[file] = tailer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// receiver is launched as a goroutine to continuously watch a tailed logfile
|
// receiver is launched as a goroutine to continuously watch a tailed logfile
|
||||||
|
|
|
||||||
|
|
@ -122,14 +122,14 @@ func (n *NetResponse) UDPGather() (map[string]string, map[string]interface{}, er
|
||||||
// Handle error
|
// Handle error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
setResult(ConnectionFailed, fields, tags, n.Expect)
|
setResult(ConnectionFailed, fields, tags, n.Expect)
|
||||||
return tags, fields, nil //nolint:nilerr // error encoded in result
|
return tags, fields, nil
|
||||||
}
|
}
|
||||||
// Connecting
|
// Connecting
|
||||||
conn, err := net.DialUDP("udp", nil, udpAddr)
|
conn, err := net.DialUDP("udp", nil, udpAddr)
|
||||||
// Handle error
|
// Handle error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
setResult(ConnectionFailed, fields, tags, n.Expect)
|
setResult(ConnectionFailed, fields, tags, n.Expect)
|
||||||
return tags, fields, nil //nolint:nilerr // error encoded in result
|
return tags, fields, nil
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
// Send string
|
// Send string
|
||||||
|
|
@ -150,7 +150,7 @@ func (n *NetResponse) UDPGather() (map[string]string, map[string]interface{}, er
|
||||||
// Handle error
|
// Handle error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
setResult(ReadFailed, fields, tags, n.Expect)
|
setResult(ReadFailed, fields, tags, n.Expect)
|
||||||
return tags, fields, nil //nolint:nilerr // error encoded in result
|
return tags, fields, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looking for string in answer
|
// Looking for string in answer
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ func (r *Raindrops) gatherURL(addr *url.URL, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
acc.AddFields("raindrops_listen", lis, tags)
|
acc.AddFields("raindrops_listen", lis, tags)
|
||||||
}
|
}
|
||||||
return nil //nolint:nilerr // nil returned on purpose
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get tag(s) for the raindrops calling/writing plugin
|
// Get tag(s) for the raindrops calling/writing plugin
|
||||||
|
|
|
||||||
|
|
@ -510,6 +510,7 @@ func (s *SQLServer) getTokenProvider() (func() (string, error), error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// return acquired token
|
// return acquired token
|
||||||
|
//nolint:unparam // token provider function always returns nil error in this scenario
|
||||||
return func() (string, error) {
|
return func() (string, error) {
|
||||||
return tokenString, nil
|
return tokenString, nil
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ func (w *WinEventLog) renderEvent(eventHandle EvtHandle) (Event, error) {
|
||||||
func (w *WinEventLog) renderLocalMessage(event Event, eventHandle EvtHandle) (Event, error) {
|
func (w *WinEventLog) renderLocalMessage(event Event, eventHandle EvtHandle) (Event, error) {
|
||||||
publisherHandle, err := openPublisherMetadata(0, event.Source.Name, w.Locale)
|
publisherHandle, err := openPublisherMetadata(0, event.Source.Name, w.Locale)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return event, nil //nolint:nilerr // We can return event without most values
|
return event, nil
|
||||||
}
|
}
|
||||||
defer _EvtClose(publisherHandle) //nolint:errcheck // Ignore error returned during Close
|
defer _EvtClose(publisherHandle) //nolint:errcheck // Ignore error returned during Close
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue