1
0
mirror of https://github.com/prometheus-community/windows_exporter.git synced 2025-04-18 19:24:05 +03:00

update: fix naming flags (renamed --collector.updates.* to --collector.update.*) (click PR number for more information) (#1986)

Signed-off-by: Melody Sofia Eroshevich <se@cloudeteer.de>
This commit is contained in:
Melo 2025-04-10 00:38:52 +02:00 committed by GitHub
parent 415c134f70
commit 5294b61339
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -84,16 +84,58 @@ func NewWithFlags(app *kingpin.Application) *Collector {
config: ConfigDefaults,
}
var (
online bool
scrapeInterval time.Duration
)
app.Flag(
"collector.updates.online",
"Deprecated: Please use collector.update.online instead",
).Default(strconv.FormatBool(ConfigDefaults.online)).BoolVar(&online)
app.Flag(
"collector.updates.scrape-interval",
"Deprecated: Please use collector.update.scrape-interval instead",
).Default(ConfigDefaults.scrapeInterval.String()).DurationVar(&scrapeInterval)
app.Flag(
"collector.update.online",
"Whether to search for updates online.",
).Default(strconv.FormatBool(ConfigDefaults.online)).BoolVar(&c.config.online)
app.Flag(
"collector.updates.scrape-interval",
"collector.update.scrape-interval",
"Define the interval of scraping Windows Update information.",
).Default(ConfigDefaults.scrapeInterval.String()).DurationVar(&c.config.scrapeInterval)
app.Action(func(*kingpin.ParseContext) error {
// Use deprecated flags only if new ones weren't explicitly set
if online {
// If the new flag is set, ignore the old one
if !c.config.online {
c.config.online = online
}
slog.Warn("Warning: --collector.updates.online is deprecated, use --collector.update.online instead.",
slog.String("collector", Name),
)
}
if scrapeInterval != ConfigDefaults.scrapeInterval {
// If the new flag is set, ignore the old one
if c.config.scrapeInterval != scrapeInterval {
c.config.scrapeInterval = scrapeInterval
}
slog.Warn("Warning: --collector.updates.scrape-interval is deprecated, use --collector.update.scrape-interval instead.",
slog.String("collector", Name),
)
}
return nil
})
return c
}
@ -121,7 +163,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
c.pendingUpdate = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "pending_info"),
"Pending Windows Updates",
"Expose information for a single pending update item",
[]string{"category", "severity", "title"},
nil,
)