From 93940569fa22d53fa1465c6af309f4603e958e0f Mon Sep 17 00:00:00 2001 From: Karl Persson <23356117+kalleep@users.noreply.github.com> Date: Thu, 22 May 2025 16:33:56 +0200 Subject: [PATCH] update: export properties so that they can be read from yaml file (#2054) --- internal/collector/update/update.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/collector/update/update.go b/internal/collector/update/update.go index 861d9bf4..ac0cdb5e 100644 --- a/internal/collector/update/update.go +++ b/internal/collector/update/update.go @@ -37,14 +37,14 @@ import ( const Name = "update" type Config struct { - online bool `yaml:"online"` - scrapeInterval time.Duration `yaml:"scrape_interval"` + Online bool `yaml:"online"` + ScrapeInterval time.Duration `yaml:"scrape_interval"` } //nolint:gochecknoglobals var ConfigDefaults = Config{ - online: false, - scrapeInterval: 6 * time.Hour, + Online: false, + ScrapeInterval: 6 * time.Hour, } var ( @@ -85,12 +85,12 @@ func NewWithFlags(app *kingpin.Application) *Collector { app.Flag( "collector.updates.online", "Whether to search for updates online.", - ).Default(strconv.FormatBool(ConfigDefaults.online)).BoolVar(&c.config.online) + ).Default(strconv.FormatBool(ConfigDefaults.Online)).BoolVar(&c.config.Online) app.Flag( "collector.updates.scrape-interval", "Define the interval of scraping Windows Update information.", - ).Default(ConfigDefaults.scrapeInterval.String()).DurationVar(&c.config.scrapeInterval) + ).Default(ConfigDefaults.ScrapeInterval.String()).DurationVar(&c.config.ScrapeInterval) return c } @@ -109,7 +109,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { ctx, cancel := context.WithCancel(context.Background()) initErrCh := make(chan error, 1) - go c.scheduleUpdateStatus(ctx, logger, initErrCh, c.config.online) + go c.scheduleUpdateStatus(ctx, logger, initErrCh, c.config.Online) c.ctxCancelFn = cancel @@ -268,7 +268,7 @@ func (c *Collector) scheduleUpdateStatus(ctx context.Context, logger *slog.Logge c.mu.Unlock() select { - case <-time.After(c.config.scrapeInterval): + case <-time.After(c.config.ScrapeInterval): case <-ctx.Done(): return }