feat: Add config file validation (#2011)

This commit is contained in:
Jan-Otto Kröpke
2025-04-24 23:45:21 +02:00
committed by GitHub
parent 554607fee2
commit 769363d157
25 changed files with 107 additions and 66 deletions

View File

@@ -34,7 +34,7 @@ import (
const Name = "dfsr"
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"sources-enabled"`
}
//nolint:gochecknoglobals

View File

@@ -41,7 +41,7 @@ const (
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -38,7 +38,7 @@ const (
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -46,7 +46,7 @@ const (
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -35,7 +35,7 @@ import (
const Name = "filetime"
type Config struct {
FilePatterns []string
FilePatterns []string `yaml:"file-patterns"`
}
//nolint:gochecknoglobals

View File

@@ -52,7 +52,7 @@ const (
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -35,10 +35,10 @@ import (
const Name = "iis"
type Config struct {
SiteInclude *regexp.Regexp `yaml:"site_include"`
SiteExclude *regexp.Regexp `yaml:"site_exclude"`
AppInclude *regexp.Regexp `yaml:"app_include"`
AppExclude *regexp.Regexp `yaml:"app_exclude"`
SiteInclude *regexp.Regexp `yaml:"site-include"`
SiteExclude *regexp.Regexp `yaml:"site-exclude"`
AppInclude *regexp.Regexp `yaml:"app-include"`
AppExclude *regexp.Regexp `yaml:"app-exclude"`
}
//nolint:gochecknoglobals

View File

@@ -38,8 +38,8 @@ import (
const Name = "logical_disk"
type Config struct {
VolumeInclude *regexp.Regexp `yaml:"volume_include"`
VolumeExclude *regexp.Regexp `yaml:"volume_exclude"`
VolumeInclude *regexp.Regexp `yaml:"volume-include"`
VolumeExclude *regexp.Regexp `yaml:"volume-exclude"`
}
//nolint:gochecknoglobals

View File

@@ -41,7 +41,7 @@ const (
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -54,7 +54,7 @@ const (
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -43,9 +43,9 @@ const (
)
type Config struct {
NicExclude *regexp.Regexp `yaml:"nic_exclude"`
NicInclude *regexp.Regexp `yaml:"nic_include"`
CollectorsEnabled []string `yaml:"collectors_enabled"`
NicExclude *regexp.Regexp `yaml:"nic-exclude"`
NicInclude *regexp.Regexp `yaml:"nic-include"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -33,7 +33,7 @@ import (
const Name = "netframework"
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -19,6 +19,7 @@ package performancecounter
import (
"github.com/prometheus-community/windows_exporter/internal/pdh"
"gopkg.in/yaml.v3"
)
type Object struct {
@@ -41,3 +42,7 @@ type Counter struct {
}
// https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/54691ebe11bb9ec32b4e35cd31fcb94a352de134/receiver/windowsperfcountersreceiver/README.md?plain=1#L150
func (*Config) UnmarshalYAML(*yaml.Node) error {
return nil
}

View File

@@ -33,8 +33,8 @@ import (
const Name = "physical_disk"
type Config struct {
DiskInclude *regexp.Regexp `yaml:"disk_include"`
DiskExclude *regexp.Regexp `yaml:"disk_exclude"`
DiskInclude *regexp.Regexp `yaml:"disk-include"`
DiskExclude *regexp.Regexp `yaml:"disk-exclude"`
}
//nolint:gochecknoglobals

View File

@@ -46,8 +46,8 @@ var printerStatusMap = map[uint16]string{
}
type Config struct {
PrinterInclude *regexp.Regexp `yaml:"printer_include"`
PrinterExclude *regexp.Regexp `yaml:"printer_exclude"`
PrinterInclude *regexp.Regexp `yaml:"include"`
PrinterExclude *regexp.Regexp `yaml:"exclude"`
}
//nolint:gochecknoglobals

View File

@@ -39,9 +39,9 @@ import (
const Name = "process"
type Config struct {
ProcessInclude *regexp.Regexp `yaml:"process_include"`
ProcessExclude *regexp.Regexp `yaml:"process_exclude"`
EnableWorkerProcess bool `yaml:"enable_iis_worker_process"` //nolint:tagliatelle
ProcessInclude *regexp.Regexp `yaml:"include"`
ProcessExclude *regexp.Regexp `yaml:"exclude"`
EnableWorkerProcess bool `yaml:"iis"`
}
//nolint:gochecknoglobals

View File

@@ -36,8 +36,8 @@ import (
const Name = "scheduled_task"
type Config struct {
TaskExclude *regexp.Regexp `yaml:"task_exclude"`
TaskInclude *regexp.Regexp `yaml:"task_include"`
TaskExclude *regexp.Regexp `yaml:"exclude"`
TaskInclude *regexp.Regexp `yaml:"include"`
}
//nolint:gochecknoglobals

View File

@@ -38,8 +38,8 @@ import (
const Name = "service"
type Config struct {
ServiceInclude *regexp.Regexp `yaml:"service_include"`
ServiceExclude *regexp.Regexp `yaml:"service_exclude"`
ServiceInclude *regexp.Regexp `yaml:"include"`
ServiceExclude *regexp.Regexp `yaml:"exclude"`
}
//nolint:gochecknoglobals

View File

@@ -32,8 +32,8 @@ import (
const Name = "smtp"
type Config struct {
ServerInclude *regexp.Regexp `yaml:"server_include"`
ServerExclude *regexp.Regexp `yaml:"server_exclude"`
ServerInclude *regexp.Regexp `yaml:"server-include"`
ServerExclude *regexp.Regexp `yaml:"server-exclude"`
}
//nolint:gochecknoglobals

View File

@@ -36,7 +36,7 @@ import (
const Name = "tcp"
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals

View File

@@ -41,7 +41,7 @@ import (
const Name = "textfile"
type Config struct {
TextFileDirectories []string `yaml:"text_file_directories"`
TextFileDirectories []string `yaml:"directories"`
}
//nolint:gochecknoglobals

View File

@@ -43,7 +43,7 @@ const (
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
CollectorsEnabled []string `yaml:"enabled"`
}
//nolint:gochecknoglobals