feat: add DNSWATCHER_SEND_TEST_NOTIFICATION env var #85

Merged
sneak merged 1 commits from feature/send-test-notification into main 2026-03-04 21:41:55 +01:00
Collaborator

When set to a truthy value, sends a startup status notification to all configured notification channels after the first full scan completes on application startup. The notification is clearly an all-ok/success message showing the number of monitored domains, hostnames, ports, and certificates.

Changes:

  • Added SendTestNotification config field reading DNSWATCHER_SEND_TEST_NOTIFICATION
  • Added maybeSendTestNotification() in watcher, called after initial RunOnce in Run
  • Added 3 watcher tests (enabled via Run, enabled via RunOnce alone, disabled)
  • Added config tests for the new field
  • Updated README: env var table, example .env, Docker example

Closes #84

When set to a truthy value, sends a startup status notification to all configured notification channels after the first full scan completes on application startup. The notification is clearly an all-ok/success message showing the number of monitored domains, hostnames, ports, and certificates. Changes: - Added `SendTestNotification` config field reading `DNSWATCHER_SEND_TEST_NOTIFICATION` - Added `maybeSendTestNotification()` in watcher, called after initial `RunOnce` in `Run` - Added 3 watcher tests (enabled via Run, enabled via RunOnce alone, disabled) - Added config tests for the new field - Updated README: env var table, example .env, Docker example Closes #84
clawbot added 1 commit 2026-03-04 13:22:32 +01:00
feat: add DNSWATCHER_SEND_TEST_NOTIFICATION env var
All checks were successful
check / check (push) Successful in 4s
ce3e63f3aa
When set to a truthy value, sends a startup status notification
to all configured notification channels after the first full scan
completes. The notification is clearly an all-ok/success message
showing the number of monitored domains, hostnames, ports, and
certificates.

Closes #84
clawbot added the needs-review label 2026-03-04 13:22:47 +01:00
Author
Collaborator

Review: PASS

Requirement Completeness Checklist

Source: issue #84

# Requirement Status Where
1 Add env var DNSWATCHER_SEND_TEST_NOTIFICATION config.go: struct field, viper default, viper read
2 When set to truthy value, waits until first full scan completes watcher.go: maybeSendTestNotification() called after RunOnce() in Run()
3 Sends startup/status notification to all configured channels Uses w.notify.SendNotification() which dispatches to Slack, Mattermost, and ntfy
4 Clearly an all-ok message, not an error or anomaly Title: " dnswatcher startup complete", priority: "success", body includes counts and "All notification channels are working."
5 Update all docs and examples to show it set to 'true' README: env var table, .env example, Docker run example all updated

Code Quality

  • Config: Clean addition following existing patterns — struct field, viper default, viper read.
  • Watcher: maybeSendTestNotification() is well-placed (after RunOnce(), before ticker loop), with early return when disabled. Notification message includes useful operational info (domain/hostname/port/cert counts).
  • Tests: Three tests cover the key scenarios — enabled via Run(), confirming RunOnce() alone doesn't trigger it, and disabled path. All use t.Parallel().
  • No linter/Makefile/Dockerfile modifications.
  • No test weakening.
  • docker build . passes (includes make check: lint, fmt, tests).
  • Branch is up to date with main — no rebase needed.

Files Changed

  • README.md — docs updated in all three relevant locations
  • internal/config/config.go — config struct + viper wiring
  • internal/config/config_test.go — default and override assertions
  • internal/watcher/watcher.go — feature implementation
  • internal/watcher/watcher_test.go — 3 new tests

Clean, focused PR. All issue requirements satisfied.

## ✅ Review: PASS ### Requirement Completeness Checklist Source: issue #84 | # | Requirement | Status | Where | |---|---|---|---| | 1 | Add env var `DNSWATCHER_SEND_TEST_NOTIFICATION` | ✅ | `config.go`: struct field, viper default, viper read | | 2 | When set to truthy value, waits until first full scan completes | ✅ | `watcher.go`: `maybeSendTestNotification()` called after `RunOnce()` in `Run()` | | 3 | Sends startup/status notification to all configured channels | ✅ | Uses `w.notify.SendNotification()` which dispatches to Slack, Mattermost, and ntfy | | 4 | Clearly an all-ok message, not an error or anomaly | ✅ | Title: "✅ dnswatcher startup complete", priority: "success", body includes counts and "All notification channels are working." | | 5 | Update all docs and examples to show it set to 'true' | ✅ | README: env var table, `.env` example, Docker run example all updated | ### Code Quality - **Config**: Clean addition following existing patterns — struct field, viper default, viper read. - **Watcher**: `maybeSendTestNotification()` is well-placed (after `RunOnce()`, before ticker loop), with early return when disabled. Notification message includes useful operational info (domain/hostname/port/cert counts). - **Tests**: Three tests cover the key scenarios — enabled via `Run()`, confirming `RunOnce()` alone doesn't trigger it, and disabled path. All use `t.Parallel()`. - **No linter/Makefile/Dockerfile modifications.** - **No test weakening.** - **`docker build .` passes** (includes `make check`: lint, fmt, tests). - **Branch is up to date with main** — no rebase needed. ### Files Changed - `README.md` — docs updated in all three relevant locations - `internal/config/config.go` — config struct + viper wiring - `internal/config/config_test.go` — default and override assertions - `internal/watcher/watcher.go` — feature implementation - `internal/watcher/watcher_test.go` — 3 new tests Clean, focused PR. All issue requirements satisfied.
clawbot added merge-ready and removed needs-review labels 2026-03-04 13:25:47 +01:00
sneak was assigned by clawbot 2026-03-04 13:25:52 +01:00
sneak merged commit 65180ad661 into main 2026-03-04 21:41:55 +01:00
sneak deleted branch feature/send-test-notification 2026-03-04 21:41:55 +01:00
Sign in to join this conversation.