chore: Enable multi-os golanglint-ci (#13599)

This commit is contained in:
Joshua Powers 2023-07-14 07:58:19 -06:00 committed by GitHub
parent 36709713e1
commit 9ede0b0c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 127 additions and 64 deletions

View File

@ -16,14 +16,33 @@ permissions:
jobs:
golangci:
name: lint-codebase
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
timeout-minutes: 360 #default
steps:
- uses: actions/setup-go@v3
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: actions/checkout@v3
- name: golangci-lint
- name: golangci-lint standard
if: runner.os != 'Windows'
uses: golangci/golangci-lint-action@v3
timeout-minutes: 60
with:
version: v1.53.2
args: --timeout 15m0s --verbose --out-${NO_FUTURE}format tab
args: --timeout 60m0s --verbose --out-${NO_FUTURE}format tab
- name: golangci-lint windows
if: runner.os == 'Windows'
uses: golangci/golangci-lint-action@v3
timeout-minutes: 60
env:
nofuture: out-format
with:
version: v1.53.2
args: --timeout 60m0s --verbose --%nofuture% tab

View File

@ -20,20 +20,6 @@ var (
varRegex = regexp.MustCompile(`\$(?:\w+|\{\w+\})`)
)
type DiskIO struct {
ps system.PS
Devices []string
DeviceTags []string
NameTemplates []string
SkipSerialNumber bool
Log telegraf.Logger
infoCache map[string]diskInfoCache
deviceFilter filter.Filter
}
// hasMeta reports whether s contains any special glob characters.
func hasMeta(s string) bool {
return strings.ContainsAny(s, "*?[")

View File

@ -10,9 +10,26 @@ import (
"path/filepath"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/filter"
"github.com/influxdata/telegraf/plugins/inputs/system"
"golang.org/x/sys/unix"
)
type DiskIO struct {
ps system.PS
Devices []string
DeviceTags []string
NameTemplates []string
SkipSerialNumber bool
Log telegraf.Logger
infoCache map[string]diskInfoCache
deviceFilter filter.Filter
}
type diskInfoCache struct {
modifiedAt int64 // Unix Nano timestamp of the last modification of the device. This value is used to invalidate the cache
udevDataPath string

View File

@ -2,7 +2,24 @@
package diskio
type diskInfoCache struct{}
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/filter"
"github.com/influxdata/telegraf/plugins/inputs/system"
)
type DiskIO struct {
ps system.PS
Devices []string
DeviceTags []string
NameTemplates []string
SkipSerialNumber bool
Log telegraf.Logger
deviceFilter filter.Filter
}
func (*DiskIO) diskInfo(_ string) (map[string]string, error) {
return nil, nil

View File

@ -3,11 +3,10 @@ package ethtool
import (
_ "embed"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/filter"
)
const pluginName = "ethtool"
//go:embed sample.conf
var sampleConfig string
@ -19,43 +18,6 @@ type Command interface {
Get(intf NamespacedInterface) (map[string]uint64, error)
}
type Ethtool struct {
// This is the list of interface names to include
InterfaceInclude []string `toml:"interface_include"`
// This is the list of interface names to ignore
InterfaceExclude []string `toml:"interface_exclude"`
// Behavior regarding metrics for downed interfaces
DownInterfaces string `toml:" down_interfaces"`
// This is the list of namespace names to include
NamespaceInclude []string `toml:"namespace_include"`
// This is the list of namespace names to ignore
NamespaceExclude []string `toml:"namespace_exclude"`
// Normalization on the key names
NormalizeKeys []string `toml:"normalize_keys"`
Log telegraf.Logger `toml:"-"`
interfaceFilter filter.Filter
namespaceFilter filter.Filter
includeNamespaces bool
// the ethtool command
command Command
}
func (*Ethtool) SampleConfig() string {
return sampleConfig
}
const (
pluginName = "ethtool"
tagInterface = "interface"
tagNamespace = "namespace"
tagDriverName = "driver"
fieldInterfaceUp = "interface_up"
)

View File

@ -19,8 +19,44 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)
const (
tagInterface = "interface"
tagNamespace = "namespace"
tagDriverName = "driver"
fieldInterfaceUp = "interface_up"
)
var downInterfacesBehaviors = []string{"expose", "skip"}
type Ethtool struct {
// This is the list of interface names to include
InterfaceInclude []string `toml:"interface_include"`
// This is the list of interface names to ignore
InterfaceExclude []string `toml:"interface_exclude"`
// Behavior regarding metrics for downed interfaces
DownInterfaces string `toml:" down_interfaces"`
// This is the list of namespace names to include
NamespaceInclude []string `toml:"namespace_include"`
// This is the list of namespace names to ignore
NamespaceExclude []string `toml:"namespace_exclude"`
// Normalization on the key names
NormalizeKeys []string `toml:"normalize_keys"`
Log telegraf.Logger `toml:"-"`
interfaceFilter filter.Filter
namespaceFilter filter.Filter
includeNamespaces bool
// the ethtool command
command Command
}
type CommandEthtool struct {
Log telegraf.Logger
namespaceGoroutines map[string]*NamespaceGoroutine

View File

@ -7,6 +7,28 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)
type Ethtool struct {
// This is the list of interface names to include
InterfaceInclude []string `toml:"interface_include"`
// This is the list of interface names to ignore
InterfaceExclude []string `toml:"interface_exclude"`
// Behavior regarding metrics for downed interfaces
DownInterfaces string `toml:" down_interfaces"`
// This is the list of namespace names to include
NamespaceInclude []string `toml:"namespace_include"`
// This is the list of namespace names to ignore
NamespaceExclude []string `toml:"namespace_exclude"`
// Normalization on the key names
NormalizeKeys []string `toml:"normalize_keys"`
Log telegraf.Logger `toml:"-"`
}
func (e *Ethtool) Init() error {
e.Log.Warn("Current platform is not supported")
return nil

View File

@ -18,16 +18,20 @@ var sysDrive = fmt.Sprintf(`%s\`, os.Getenv("SystemDrive")) // C:\
// include Name as a tag, FreeSpace as a field, and Purpose as a known-null class property
var testQuery = Query{
Namespace: "ROOT\\cimv2",
ClassName: "Win32_Volume",
Properties: []string{"Name", "FreeSpace", "Purpose"},
Namespace: "ROOT\\cimv2",
ClassName: "Win32_Volume",
Properties: []string{"Name", "FreeSpace", "Purpose"},
//nolint:gocritic // sprintfQuotedString - "%s" used by purpose, string escaping is done by special function
Filter: fmt.Sprintf(`NOT Name LIKE "\\\\?\\%%" AND Name LIKE "%s"`, regexp.QuoteMeta(sysDrive)),
TagPropertiesInclude: []string{"Name"},
tagFilter: nil, // this is filled in by CompileInputs()
}
//nolint:gocritic // sprintfQuotedString - "%s" used by purpose, string escaping is done by special function
var expectedWql = fmt.Sprintf(
`SELECT Name, FreeSpace, Purpose FROM Win32_Volume WHERE NOT Name LIKE "\\\\?\\%%" AND Name LIKE "%s"`,
regexp.QuoteMeta(sysDrive))
regexp.QuoteMeta(sysDrive),
)
// test buildWqlStatements
func TestWmi_buildWqlStatements(t *testing.T) {