From 3b8302cf68f5b2737dc3261e19e001b4800a3e68 Mon Sep 17 00:00:00 2001 From: Pawel Zak Date: Sat, 19 Oct 2024 11:42:28 +0200 Subject: [PATCH] fix linter findings for windows and darwin --- plugins/inputs/ethtool/ethtool.go | 8 -------- plugins/inputs/ethtool/ethtool_linux.go | 8 ++++++++ plugins/inputs/ethtool/namespace.go | 16 ---------------- plugins/inputs/ethtool/namespace_linux.go | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 plugins/inputs/ethtool/namespace.go diff --git a/plugins/inputs/ethtool/ethtool.go b/plugins/inputs/ethtool/ethtool.go index d59039ace0c4a..fe3c34bf91c13 100644 --- a/plugins/inputs/ethtool/ethtool.go +++ b/plugins/inputs/ethtool/ethtool.go @@ -10,14 +10,6 @@ var sampleConfig string const pluginName = "ethtool" -type command interface { - init() error - driverName(intf namespacedInterface) (string, error) - interfaces(includeNamespaces bool) ([]namespacedInterface, error) - stats(intf namespacedInterface) (map[string]uint64, error) - get(intf namespacedInterface) (map[string]uint64, error) -} - func (*Ethtool) SampleConfig() string { return sampleConfig } diff --git a/plugins/inputs/ethtool/ethtool_linux.go b/plugins/inputs/ethtool/ethtool_linux.go index 0710a3dc1b56a..a0e61e7ec1490 100644 --- a/plugins/inputs/ethtool/ethtool_linux.go +++ b/plugins/inputs/ethtool/ethtool_linux.go @@ -57,6 +57,14 @@ type Ethtool struct { command command } +type command interface { + init() error + driverName(intf namespacedInterface) (string, error) + interfaces(includeNamespaces bool) ([]namespacedInterface, error) + stats(intf namespacedInterface) (map[string]uint64, error) + get(intf namespacedInterface) (map[string]uint64, error) +} + type commandEthtool struct { log telegraf.Logger namespaceGoroutines map[string]*namespaceGoroutine diff --git a/plugins/inputs/ethtool/namespace.go b/plugins/inputs/ethtool/namespace.go deleted file mode 100644 index bb2f8f736a627..0000000000000 --- a/plugins/inputs/ethtool/namespace.go +++ /dev/null @@ -1,16 +0,0 @@ -package ethtool - -import "net" - -type namespace interface { - name() string - interfaces() ([]namespacedInterface, error) - driverName(intf namespacedInterface) (string, error) - stats(intf namespacedInterface) (map[string]uint64, error) - get(intf namespacedInterface) (map[string]uint64, error) -} - -type namespacedInterface struct { - net.Interface - namespace namespace -} diff --git a/plugins/inputs/ethtool/namespace_linux.go b/plugins/inputs/ethtool/namespace_linux.go index 88d109650400a..6d565b13230d9 100644 --- a/plugins/inputs/ethtool/namespace_linux.go +++ b/plugins/inputs/ethtool/namespace_linux.go @@ -1,3 +1,5 @@ +//go:build linux + package ethtool import ( @@ -11,6 +13,19 @@ import ( "github.com/influxdata/telegraf" ) +type namespace interface { + name() string + interfaces() ([]namespacedInterface, error) + driverName(intf namespacedInterface) (string, error) + stats(intf namespacedInterface) (map[string]uint64, error) + get(intf namespacedInterface) (map[string]uint64, error) +} + +type namespacedInterface struct { + net.Interface + namespace namespace +} + type namespacedAction struct { result chan<- namespacedResult f func(*namespaceGoroutine) (interface{}, error)