chore: Enable multi-os golanglint-ci (#13599)
This commit is contained in:
parent
36709713e1
commit
9ede0b0c49
|
|
@ -16,14 +16,33 @@ permissions:
|
||||||
jobs:
|
jobs:
|
||||||
golangci:
|
golangci:
|
||||||
name: lint-codebase
|
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:
|
steps:
|
||||||
- uses: actions/setup-go@v3
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.20'
|
||||||
- uses: actions/checkout@v3
|
- name: golangci-lint standard
|
||||||
- name: golangci-lint
|
if: runner.os != 'Windows'
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
timeout-minutes: 60
|
||||||
with:
|
with:
|
||||||
version: v1.53.2
|
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
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,6 @@ var (
|
||||||
varRegex = regexp.MustCompile(`\$(?:\w+|\{\w+\})`)
|
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.
|
// hasMeta reports whether s contains any special glob characters.
|
||||||
func hasMeta(s string) bool {
|
func hasMeta(s string) bool {
|
||||||
return strings.ContainsAny(s, "*?[")
|
return strings.ContainsAny(s, "*?[")
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,26 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf"
|
||||||
|
"github.com/influxdata/telegraf/filter"
|
||||||
|
"github.com/influxdata/telegraf/plugins/inputs/system"
|
||||||
"golang.org/x/sys/unix"
|
"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 {
|
type diskInfoCache struct {
|
||||||
modifiedAt int64 // Unix Nano timestamp of the last modification of the device. This value is used to invalidate the cache
|
modifiedAt int64 // Unix Nano timestamp of the last modification of the device. This value is used to invalidate the cache
|
||||||
udevDataPath string
|
udevDataPath string
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,24 @@
|
||||||
|
|
||||||
package diskio
|
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) {
|
func (*DiskIO) diskInfo(_ string) (map[string]string, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,10 @@ package ethtool
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/influxdata/telegraf/filter"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const pluginName = "ethtool"
|
||||||
|
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
var sampleConfig string
|
var sampleConfig string
|
||||||
|
|
||||||
|
|
@ -19,43 +18,6 @@ type Command interface {
|
||||||
Get(intf NamespacedInterface) (map[string]uint64, error)
|
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 {
|
func (*Ethtool) SampleConfig() string {
|
||||||
return sampleConfig
|
return sampleConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
pluginName = "ethtool"
|
|
||||||
tagInterface = "interface"
|
|
||||||
tagNamespace = "namespace"
|
|
||||||
tagDriverName = "driver"
|
|
||||||
fieldInterfaceUp = "interface_up"
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,44 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
tagInterface = "interface"
|
||||||
|
tagNamespace = "namespace"
|
||||||
|
tagDriverName = "driver"
|
||||||
|
fieldInterfaceUp = "interface_up"
|
||||||
|
)
|
||||||
|
|
||||||
var downInterfacesBehaviors = []string{"expose", "skip"}
|
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 {
|
type CommandEthtool struct {
|
||||||
Log telegraf.Logger
|
Log telegraf.Logger
|
||||||
namespaceGoroutines map[string]*NamespaceGoroutine
|
namespaceGoroutines map[string]*NamespaceGoroutine
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,28 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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 {
|
func (e *Ethtool) Init() error {
|
||||||
e.Log.Warn("Current platform is not supported")
|
e.Log.Warn("Current platform is not supported")
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -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
|
// include Name as a tag, FreeSpace as a field, and Purpose as a known-null class property
|
||||||
var testQuery = Query{
|
var testQuery = Query{
|
||||||
Namespace: "ROOT\\cimv2",
|
Namespace: "ROOT\\cimv2",
|
||||||
ClassName: "Win32_Volume",
|
ClassName: "Win32_Volume",
|
||||||
Properties: []string{"Name", "FreeSpace", "Purpose"},
|
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)),
|
Filter: fmt.Sprintf(`NOT Name LIKE "\\\\?\\%%" AND Name LIKE "%s"`, regexp.QuoteMeta(sysDrive)),
|
||||||
TagPropertiesInclude: []string{"Name"},
|
TagPropertiesInclude: []string{"Name"},
|
||||||
tagFilter: nil, // this is filled in by CompileInputs()
|
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(
|
var expectedWql = fmt.Sprintf(
|
||||||
`SELECT Name, FreeSpace, Purpose FROM Win32_Volume WHERE NOT Name LIKE "\\\\?\\%%" AND Name LIKE "%s"`,
|
`SELECT Name, FreeSpace, Purpose FROM Win32_Volume WHERE NOT Name LIKE "\\\\?\\%%" AND Name LIKE "%s"`,
|
||||||
regexp.QuoteMeta(sysDrive))
|
regexp.QuoteMeta(sysDrive),
|
||||||
|
)
|
||||||
|
|
||||||
// test buildWqlStatements
|
// test buildWqlStatements
|
||||||
func TestWmi_buildWqlStatements(t *testing.T) {
|
func TestWmi_buildWqlStatements(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue