config: use /var/lib/dnswatcher as default data directory #89

Merged
sneak merged 1 commits from fix/88-absolute-datadir into main 2026-03-20 06:56:10 +01:00
Collaborator

Closes issue #88.

Changes the default DNSWATCHER_DATA_DIR from the relative path ./data to the absolute path /var/lib/dnswatcher, following the Filesystem Hierarchy Standard convention for variable application state data.

Changes

  • internal/config/config.go: Changed the Viper default for DATA_DIR from "./data" to "/var/lib/"+name, where name is the application name ("dnswatcher"). This makes the default derived from the app name rather than hardcoded.
  • internal/config/config_test.go: Updated TestNew_DefaultValues and TestStatePath to expect the new absolute default.
  • README.md: Updated the environment variable table and .env example to show /var/lib/dnswatcher as the default.

The Dockerfile already set ENV DNSWATCHER_DATA_DIR=/var/lib/dnswatcher explicitly, so Docker deployments are unaffected. This change makes the code default consistent with the Docker configuration.

docker build . passes all checks (fmt, lint, tests, build).

Closes [issue #88](https://git.eeqj.de/sneak/dnswatcher/issues/88). Changes the default `DNSWATCHER_DATA_DIR` from the relative path `./data` to the absolute path `/var/lib/dnswatcher`, following the [Filesystem Hierarchy Standard](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s08.html) convention for variable application state data. ## Changes - **`internal/config/config.go`**: Changed the Viper default for `DATA_DIR` from `"./data"` to `"/var/lib/"+name`, where `name` is the application name ("dnswatcher"). This makes the default derived from the app name rather than hardcoded. - **`internal/config/config_test.go`**: Updated `TestNew_DefaultValues` and `TestStatePath` to expect the new absolute default. - **`README.md`**: Updated the environment variable table and `.env` example to show `/var/lib/dnswatcher` as the default. The Dockerfile already set `ENV DNSWATCHER_DATA_DIR=/var/lib/dnswatcher` explicitly, so Docker deployments are unaffected. This change makes the code default consistent with the Docker configuration. `docker build .` passes all checks (fmt, lint, tests, build).
clawbot added 1 commit 2026-03-17 13:11:29 +01:00
config: use /var/lib/dnswatcher as default data directory
All checks were successful
check / check (push) Successful in 46s
b4f986a2e5
Change the default DATA_DIR from the relative path './data' to the
absolute path '/var/lib/dnswatcher', following the FHS convention for
application state data.

The default is derived from the application name passed to setupViper,
so it will always match /var/lib/<appname>.

Updated README environment variable table and .env example to reflect
the new default. Tests updated accordingly.
clawbot added the needs-review label 2026-03-17 13:12:36 +01:00
Author
Collaborator

Review: PR #89 — config: use /var/lib/dnswatcher as default data directory

Policy Divergences

No policy violations found.

  • No new external references introduced (pinning N/A)
  • No modifications to Makefile, .golangci.yml, CI config, or Dockerfile
  • No weakened test assertions — tests updated to match new correct default
  • README updated consistently with code change
  • No new exported types/functions (test coverage check N/A)

Requirements Checklist (issue #88)

Requirement Status
Data directory default must not be relative Met — changed from ./data to /var/lib/dnswatcher
Use /var/lib/<appname> Met — uses /var/lib/ + name where name is the app name ("dnswatcher")

Code Review

  • internal/config/config.go: Default changed from "./data" to "/var/lib/"+name. Correct — derives from app name rather than hardcoding, and name has a fallback to "dnswatcher" if Globals.Appname is empty.
  • internal/config/config_test.go: TestNew_DefaultValues and TestStatePath updated to expect /var/lib/dnswatcher. Assertions are correct and not weakened.
  • README.md: Environment variable table and .env example both updated to show /var/lib/dnswatcher. Consistent with code.
  • Dockerfile already had ENV DNSWATCHER_DATA_DIR=/var/lib/dnswatcher — Docker deployments unaffected.

Build Result

docker build .PASS (all cached layers, make check passes: fmt, lint, tests, build).

Branch is already rebased on main (single commit ahead, no conflicts).

Verdict: PASS

Minimal, focused change that correctly implements the issue requirement. No policy violations, no scope creep, no cheating, docs consistent with code.

## Review: [PR #89](https://git.eeqj.de/sneak/dnswatcher/pulls/89) — config: use /var/lib/dnswatcher as default data directory ### Policy Divergences No policy violations found. - No new external references introduced (pinning N/A) - No modifications to Makefile, `.golangci.yml`, CI config, or Dockerfile - No weakened test assertions — tests updated to match new correct default - README updated consistently with code change - No new exported types/functions (test coverage check N/A) ### Requirements Checklist ([issue #88](https://git.eeqj.de/sneak/dnswatcher/issues/88)) | Requirement | Status | |---|---| | Data directory default must not be relative | ✅ Met — changed from `./data` to `/var/lib/dnswatcher` | | Use `/var/lib/<appname>` | ✅ Met — uses `/var/lib/` + `name` where `name` is the app name ("dnswatcher") | ### Code Review - `internal/config/config.go`: Default changed from `"./data"` to `"/var/lib/"+name`. Correct — derives from app name rather than hardcoding, and `name` has a fallback to `"dnswatcher"` if `Globals.Appname` is empty. - `internal/config/config_test.go`: `TestNew_DefaultValues` and `TestStatePath` updated to expect `/var/lib/dnswatcher`. Assertions are correct and not weakened. - `README.md`: Environment variable table and `.env` example both updated to show `/var/lib/dnswatcher`. Consistent with code. - Dockerfile already had `ENV DNSWATCHER_DATA_DIR=/var/lib/dnswatcher` — Docker deployments unaffected. ### Build Result `docker build .` — **PASS** (all cached layers, `make check` passes: fmt, lint, tests, build). Branch is already rebased on `main` (single commit ahead, no conflicts). ### Verdict: PASS Minimal, focused change that correctly implements the issue requirement. No policy violations, no scope creep, no cheating, docs consistent with code.
clawbot added merge-ready and removed needs-review labels 2026-03-17 13:16:31 +01:00
sneak was assigned by clawbot 2026-03-17 13:16:31 +01:00
sneak merged commit f788037bfb into main 2026-03-20 06:56:10 +01:00
sneak deleted branch fix/88-absolute-datadir 2026-03-20 06:56:10 +01:00
Sign in to join this conversation.