chore: Fix linter findings for Darwin (#12958)
Co-authored-by: Pawel Zak <Pawel Zak>
This commit is contained in:
parent
d14ea26100
commit
73076bb9fa
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/awnumar/memguard"
|
"github.com/awnumar/memguard"
|
||||||
)
|
)
|
||||||
|
|
||||||
func protect(secret []byte) error {
|
func protect(_ []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *CGroup) Gather(acc telegraf.Accumulator) error {
|
func (*CGroup) Gather(_ telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ package diskio
|
||||||
|
|
||||||
type diskInfoCache struct{}
|
type diskInfoCache struct{}
|
||||||
|
|
||||||
func (d *DiskIO) diskInfo(devName string) (map[string]string, error) {
|
func (*DiskIO) diskInfo(_ string) (map[string]string, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -12,6 +12,6 @@ func resolveName(name string) string {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDeviceWWID(name string) string {
|
func getDeviceWWID(_ string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *DMCache) Gather(acc telegraf.Accumulator) error {
|
func (*DMCache) Gather(_ telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ import (
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
var sampleConfig string
|
var sampleConfig string
|
||||||
|
|
||||||
var downInterfacesBehaviors = []string{"expose", "skip"}
|
|
||||||
|
|
||||||
type Command interface {
|
type Command interface {
|
||||||
Init() error
|
Init() error
|
||||||
DriverName(intf NamespacedInterface) (string, error)
|
DriverName(intf NamespacedInterface) (string, error)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var downInterfacesBehaviors = []string{"expose", "skip"}
|
||||||
|
|
||||||
type CommandEthtool struct {
|
type CommandEthtool struct {
|
||||||
Log telegraf.Logger
|
Log telegraf.Logger
|
||||||
namespaceGoroutines map[string]*NamespaceGoroutine
|
namespaceGoroutines map[string]*NamespaceGoroutine
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ func (e *Ethtool) Init() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Ethtool) Gather(acc telegraf.Accumulator) error {
|
func (*Ethtool) Gather(_ telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ func (i *Infiniband) Init() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ *Infiniband) Gather(acc telegraf.Accumulator) error {
|
func (*Infiniband) Gather(_ telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//go:build linux
|
||||||
|
|
||||||
package intel_powerstat
|
package intel_powerstat
|
||||||
|
|
||||||
type msrData struct {
|
type msrData struct {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//go:build linux
|
||||||
|
|
||||||
// Code generated by mockery v2.12.3. DO NOT EDIT.
|
// Code generated by mockery v2.12.3. DO NOT EDIT.
|
||||||
|
|
||||||
package intel_powerstat
|
package intel_powerstat
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//go:build linux
|
||||||
|
|
||||||
// Code generated by mockery v2.12.3. DO NOT EDIT.
|
// Code generated by mockery v2.12.3. DO NOT EDIT.
|
||||||
|
|
||||||
package intel_powerstat
|
package intel_powerstat
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//go:build linux
|
||||||
|
|
||||||
// Code generated by mockery v2.12.3. DO NOT EDIT.
|
// Code generated by mockery v2.12.3. DO NOT EDIT.
|
||||||
|
|
||||||
package intel_powerstat
|
package intel_powerstat
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ func (k *Kernel) Init() error {
|
||||||
k.Log.Warn("current platform is not supported")
|
k.Log.Warn("current platform is not supported")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (*Kernel) SampleConfig() string { return sampleConfig }
|
func (*Kernel) SampleConfig() string { return sampleConfig }
|
||||||
func (*Kernel) Gather(acc telegraf.Accumulator) error { return nil }
|
func (*Kernel) Gather(_ telegraf.Accumulator) error { return nil }
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("kernel", func() telegraf.Input {
|
inputs.Add("kernel", func() telegraf.Input {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,28 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"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) {
|
func TestPowerdnsGeneratesMetrics(t *testing.T) {
|
||||||
// We create a fake server to return test data
|
// We create a fake server to return test data
|
||||||
randomNumber := int64(5239846799706671610)
|
randomNumber := int64(5239846799706671610)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
package powerdns
|
package powerdns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type statServer struct{}
|
|
||||||
|
|
||||||
var metrics = "corrupt-packets=0,deferred-cache-inserts=0,deferred-cache-lookup=0," +
|
var metrics = "corrupt-packets=0,deferred-cache-inserts=0,deferred-cache-lookup=0," +
|
||||||
"dnsupdate-answers=0,dnsupdate-changes=0,dnsupdate-queries=0," +
|
"dnsupdate-answers=0,dnsupdate-changes=0,dnsupdate-queries=0," +
|
||||||
"dnsupdate-refused=0,packetcache-hit=0,packetcache-miss=1,packetcache-size=0," +
|
"dnsupdate-refused=0,packetcache-hit=0,packetcache-miss=1,packetcache-size=0," +
|
||||||
|
|
@ -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," +
|
"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,"
|
"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) {
|
func TestPowerdnsParseMetrics(t *testing.T) {
|
||||||
p := &Powerdns{
|
p := &Powerdns{
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ func (k *Synproxy) Init() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *Synproxy) Gather(acc telegraf.Accumulator) error {
|
func (*Synproxy) Gather(_ telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ func (w *Wireless) Init() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Wireless) Gather(acc telegraf.Accumulator) error {
|
func (*Wireless) Gather(_ telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (z *Zfs) Gather(acc telegraf.Accumulator) error {
|
func (*Zfs) Gather(_ telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import (
|
||||||
func (o *OS) createKeyringConfig() (keyring.Config, error) {
|
func (o *OS) createKeyringConfig() (keyring.Config, error) {
|
||||||
passwd, err := o.Password.Get()
|
passwd, err := o.Password.Get()
|
||||||
if err != nil {
|
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)
|
defer config.ReleaseSecret(passwd)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue