Standardize codebase consistency: naming, JSON tags, logging, error wrapping

- JSON tags: fix snake_case to camelCase in dnsmasq (configFile, domainsConfigured,
  lastRestart), crowdsec Machine (lastPush, lastHeartbeat), network (primaryIP,
  primaryInterface). cscli raw parsing structs keep snake_case to match CLI output.
- Error wrapping: fix %v to %w in enableAuthelia for proper error chain preservation
- Naming: rename dnsmasq.ConfigGenerator to dnsmasq.Manager (matches all other packages),
  rename ServiceStatus to Status in dnsmasq and haproxy (matches authelia, crowdsec, etc.)
- Logging: standardize all slog calls to use "component" key instead of message prefixes.
  Affects reconcile, dnsfilter, ddns — now consistent with dnsmasq, haproxy, nftables, sse.
This commit is contained in:
2026-07-14 04:38:48 +00:00
parent 428d47f876
commit 3172e56288
13 changed files with 135 additions and 116 deletions

View File

@@ -75,7 +75,7 @@ func (r *Runner) Trigger() {
func (r *Runner) run(ctx context.Context, intervalHours int) {
interval := time.Duration(intervalHours) * time.Hour
slog.Info("dns-filter: runner started", "interval", interval)
slog.Info("runner started", "component", "dns-filter", "interval", interval)
// Immediate update on start
r.updateAndCompile(ctx)
@@ -89,7 +89,7 @@ func (r *Runner) run(ctx context.Context, intervalHours int) {
r.mu.Lock()
r.running = false
r.mu.Unlock()
slog.Info("dns-filter: runner stopped")
slog.Info("runner stopped", "component", "dns-filter")
return
case <-ticker.C:
r.updateAndCompile(ctx)
@@ -101,11 +101,11 @@ func (r *Runner) run(ctx context.Context, intervalHours int) {
func (r *Runner) updateAndCompile(ctx context.Context) {
if err := r.manager.UpdateLists(ctx); err != nil {
slog.Error("dns-filter: update failed", "error", err)
slog.Error("update failed", "component", "dns-filter", "error", err)
}
if _, err := r.manager.Compile(); err != nil {
slog.Error("dns-filter: compile failed", "error", err)
slog.Error("compile failed", "component", "dns-filter", "error", err)
return
}