Remove fluent-style kingpin

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2023-04-16 11:45:07 +02:00
parent a105e088b3
commit da6898afc4
15 changed files with 487 additions and 252 deletions

View File

@@ -12,15 +12,14 @@ import (
"github.com/prometheus/client_golang/prometheus"
)
const (
FlagNicBlacklist = "collector.net.nic-blacklist"
FlagNicWhitelist = "collector.net.nic-whitelist"
)
var (
nicWhitelist = kingpin.Flag(
"collector.net.nic-whitelist",
"Regexp of NIC:s to whitelist. NIC name must both match whitelist and not match blacklist to be included.",
).Default(".+").String()
nicBlacklist = kingpin.Flag(
"collector.net.nic-blacklist",
"Regexp of NIC:s to blacklist. NIC name must both match whitelist and not match blacklist to be included.",
).Default("").String()
nicWhitelist *string
nicBlacklist *string
nicNameToUnderscore = regexp.MustCompile("[^a-zA-Z0-9]")
)
@@ -44,6 +43,18 @@ type NetworkCollector struct {
nicBlacklistPattern *regexp.Regexp
}
// newNetworkCollectorFlags ...
func newNetworkCollectorFlags(app *kingpin.Application) {
nicWhitelist = app.Flag(
FlagNicWhitelist,
"Regexp of NIC:s to whitelist. NIC name must both match whitelist and not match blacklist to be included.",
).Default(".+").String()
nicBlacklist = app.Flag(
FlagNicBlacklist,
"Regexp of NIC:s to blacklist. NIC name must both match whitelist and not match blacklist to be included.",
).Default("").String()
}
// newNetworkCollector ...
func newNetworkCollector() (Collector, error) {
const subsystem = "net"