Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix linter findings for Darwin #12958

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/secret_without_mlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/awnumar/memguard"
)

func protect(secret []byte) error {
func protect(_ []byte) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/cgroup/cgroup_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import (
"github.com/influxdata/telegraf"
)

func (g *CGroup) Gather(acc telegraf.Accumulator) error {
func (*CGroup) Gather(_ telegraf.Accumulator) error {
return nil
}
4 changes: 2 additions & 2 deletions plugins/inputs/diskio/diskio_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ package diskio

type diskInfoCache struct{}

func (d *DiskIO) diskInfo(devName string) (map[string]string, error) {
func (*DiskIO) diskInfo(_ string) (map[string]string, error) {
return nil, nil
}

func resolveName(name string) string {
return name
}

func getDeviceWWID(name string) string {
func getDeviceWWID(_ string) string {
return ""
}
2 changes: 1 addition & 1 deletion plugins/inputs/dmcache/dmcache_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/influxdata/telegraf"
)

func (c *DMCache) Gather(acc telegraf.Accumulator) error {
func (*DMCache) Gather(_ telegraf.Accumulator) error {
return nil
}

Expand Down
2 changes: 0 additions & 2 deletions plugins/inputs/ethtool/ethtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
//go:embed sample.conf
var sampleConfig string

var downInterfacesBehaviors = []string{"expose", "skip"}

type Command interface {
Init() error
DriverName(intf NamespacedInterface) (string, error)
Expand Down
2 changes: 2 additions & 0 deletions plugins/inputs/ethtool/ethtool_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)

var downInterfacesBehaviors = []string{"expose", "skip"}

type CommandEthtool struct {
Log telegraf.Logger
namespaceGoroutines map[string]*NamespaceGoroutine
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/ethtool/ethtool_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (e *Ethtool) Init() error {
return nil
}

func (e *Ethtool) Gather(acc telegraf.Accumulator) error {
func (*Ethtool) Gather(_ telegraf.Accumulator) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/infiniband/infiniband_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (i *Infiniband) Init() error {
return nil
}

func (_ *Infiniband) Gather(acc telegraf.Accumulator) error {
func (*Infiniband) Gather(_ telegraf.Accumulator) error {
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/inputs/intel_powerstat/dto.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

package intel_powerstat

type msrData struct {
Expand Down
2 changes: 2 additions & 0 deletions plugins/inputs/intel_powerstat/file_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/inputs/intel_powerstat/msr_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/inputs/intel_powerstat/rapl_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions plugins/inputs/kernel/kernel_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func (k *Kernel) Init() error {
k.Log.Warn("current platform is not supported")
return nil
}
func (*Kernel) SampleConfig() string { return sampleConfig }
func (*Kernel) Gather(acc telegraf.Accumulator) error { return nil }
func (*Kernel) SampleConfig() string { return sampleConfig }
func (*Kernel) Gather(_ telegraf.Accumulator) error { return nil }

func init() {
inputs.Add("kernel", func() telegraf.Input {
Expand Down
22 changes: 22 additions & 0 deletions plugins/inputs/powerdns/powerdns_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ import (
"github.com/stretchr/testify/require"
)

type statServer struct{}

func (s statServer) serverSocket(l net.Listener) {
for {
conn, err := l.Accept()
if err != nil {
return
}

go func(c net.Conn) {
buf := make([]byte, 1024)
n, _ := c.Read(buf)

data := buf[:n]
if string(data) == "show * \n" {
c.Write([]byte(metrics)) //nolint:errcheck,revive // ignore the returned error as we need to close the socket anyway
c.Close() //nolint:revive // ignore the returned error as we cannot do anything about it anyway
}
}(conn)
}
}

func TestPowerdnsGeneratesMetrics(t *testing.T) {
// We create a fake server to return test data
randomNumber := int64(5239846799706671610)
Expand Down
23 changes: 0 additions & 23 deletions plugins/inputs/powerdns/powerdns_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package powerdns

import (
"net"
"testing"

"github.com/influxdata/telegraf/testutil"
)

type statServer struct{}

var metrics = "corrupt-packets=0,deferred-cache-inserts=0,deferred-cache-lookup=0," +
"dnsupdate-answers=0,dnsupdate-changes=0,dnsupdate-queries=0," +
"dnsupdate-refused=0,packetcache-hit=0,packetcache-miss=1,packetcache-size=0," +
Expand Down Expand Up @@ -44,26 +41,6 @@ var intOverflowMetrics = "corrupt-packets=18446744073709550195,deferred-cache-in
"key-cache-size=0,latency=26,meta-cache-size=0,qsize-q=0," +
"signature-cache-size=0,sys-msec=2889,uptime=86317,user-msec=2167,"

func (s statServer) serverSocket(l net.Listener) {
for {
conn, err := l.Accept()
if err != nil {
return
}

go func(c net.Conn) {
buf := make([]byte, 1024)
n, _ := c.Read(buf)

data := buf[:n]
if string(data) == "show * \n" {
c.Write([]byte(metrics)) //nolint:errcheck,revive // ignore the returned error as we need to close the socket anyway
c.Close() //nolint:revive // ignore the returned error as we cannot do anything about it anyway
}
}(conn)
}
}

func TestPowerdnsParseMetrics(t *testing.T) {
p := &Powerdns{
Log: testutil.Logger{},
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/synproxy/synproxy_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (k *Synproxy) Init() error {
return nil
}

func (k *Synproxy) Gather(acc telegraf.Accumulator) error {
func (*Synproxy) Gather(_ telegraf.Accumulator) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/wireless/wireless_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (w *Wireless) Init() error {
return nil
}

func (w *Wireless) Gather(acc telegraf.Accumulator) error {
func (*Wireless) Gather(_ telegraf.Accumulator) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/zfs/zfs_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)

func (z *Zfs) Gather(acc telegraf.Accumulator) error {
func (*Zfs) Gather(_ telegraf.Accumulator) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/secretstores/os/os_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func (o *OS) createKeyringConfig() (keyring.Config, error) {
passwd, err := o.Password.Get()
if err != nil {
return keyring.Config{}, fmt.Errorf("getting password failed: %v", err)
return keyring.Config{}, fmt.Errorf("getting password failed: %w", err)
}
defer config.ReleaseSecret(passwd)

Expand Down