Refactor settings handling to support context-based reloading and add utility functions for context management
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-19 11:06:05 +11:00
parent f2d6b3158b
commit 504621f80d
5 changed files with 50 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ import (
"vctp/db/queries"
"vctp/internal/metrics"
"vctp/internal/report"
"vctp/internal/settings"
"vctp/internal/utils"
"vctp/internal/vcenter"
@@ -116,8 +117,11 @@ func (c *CronTask) RunVcenterSnapshotHourly(ctx context.Context, logger *slog.Lo
// Best-effort cleanup of legacy IsPresent columns to simplify inserts.
c.dropLegacyIsPresentColumns(jobCtx)
// reload settings in case vcenter list has changed
c.Settings.ReadYMLSettings()
// Reload settings once for this run (for example, in case vCenter list has changed).
if err := c.Settings.ReadYMLSettings(); err != nil {
return err
}
ctx = settings.MarkReloadedInContext(ctx, c.Settings)
if c.FirstHourlySnapshotCheck {
if err := report.EnsureSnapshotRegistry(ctx, c.Database); err != nil {