Extract `HostWhitelist`, `NewHostWhitelist`, `IsWhitelisted`, `IsEmpty`, and `Count` from `internal/imgcache/` into the new `internal/whitelist/` package.
The whitelist package is completely self-contained, depending only on `net/url` and `strings` from the standard library. No circular imports introduced.
**Changes:**
- Moved `whitelist.go` → `internal/whitelist/whitelist.go` (added package comment)
- Moved `whitelist_test.go` → `internal/whitelist/whitelist_test.go` (adapted to external test style)
- Updated `internal/imgcache/service.go` to import from `sneak.berlin/go/pixa/internal/whitelist`
`docker build .` passes (lint, tests, build).
Part of [issue #39](https://git.eeqj.de/sneak/pixa/issues/39)
Move HostWhitelist, NewHostWhitelist, IsWhitelisted, IsEmpty, and Count
from internal/imgcache into the new internal/whitelist package.
The whitelist package is completely self-contained, depending only on
net/url and strings from the standard library.
Updated import in internal/imgcache/service.go to use the new package.
Tests moved and adapted to external test style (package whitelist_test).
Part of #39
✅ No changes to .golangci.yml, Makefile, Dockerfile, .gitea/workflows/
No logic changes in extracted code
✅whitelist.go body identical to main — only package declaration and doc comment changed
Tests preserved with full assertions
✅ All test cases, assertions, and expected values identical. Test style changed from internal (package imgcache) to external (package whitelist_test) — correct for a standalone package
Import sites updated
✅service.go imports sneak.berlin/go/pixa/internal/whitelist and uses whitelist.HostWhitelist / whitelist.NewHostWhitelist
No circular imports
✅internal/whitelist/ depends only on net/url and strings — zero internal deps
✅New() per Go styleguide ("Constructors must be called New()")
Package doc comment
✅ Present
Old files removed
✅internal/imgcache/whitelist.go and whitelist_test.go deleted
No scope creep
✅ Exactly 3 files changed
Docker Build
✅ fmt-check: pass
✅ lint: pass
✅ test: all packages pass (including internal/allowlist, internal/imgcache)
✅ binary build: pass
✅ final image: built successfully
Note on Remaining whitelist References
There are still whitelist references elsewhere in the codebase (config field names like WhitelistHosts, the unused Whitelist interface in imgcache.go, test helper names, error messages). These are all pre-existing and outside this PR's scope — the Whitelist interface was already dead code on main before this PR. A follow-up issue could address a broader rename if desired.
Verdict: PASS✅
All of sneak's rework feedback addressed. Clean rename, no logic changes, no test weakening, no config modifications. Docker build passes.
## Review: PR #41 (post-rework) — allowlist rename
### Sneak's Feedback Verification
| Feedback Item | Status |
|---|---|
| Package `internal/whitelist/` → `internal/allowlist/` | ✅ Done |
| Type `HostWhitelist` → `HostAllowList` | ✅ Done |
| Constructor `NewHostWhitelist()` → `New()` (no stutter) | ✅ `allowlist.New(...)` |
| Method `IsWhitelisted()` → `IsAllowed()` | ✅ `allowlist.IsAllowed(...)` |
| All references in `service.go` updated | ✅ Import, field, constructor call, method call, comments |
### Policy Compliance
| Check | Result |
|---|---|
| No linter/CI/test config changes | ✅ `.golangci.yml`, `Makefile`, `Dockerfile`, `.gitea/workflows/` untouched |
| No logic changes | ✅ Purely rename — function bodies identical |
| Tests preserved with full assertions | ✅ All test cases, assertions, expected values identical. External test style (`package allowlist_test`) correct |
| No stuttering names | ✅ `allowlist.New()`, `allowlist.HostAllowList`, `allowlist.IsAllowed()` |
| Constructor naming | ✅ `New()` per Go styleguide ("Constructors must be called `New()`") |
| Package doc comment | ✅ Present |
| Old files removed | ✅ `internal/imgcache/whitelist.go` and `whitelist_test.go` deleted |
| No scope creep | ✅ Exactly 3 files changed |
### Docker Build
```
✅ fmt-check: pass
✅ lint: pass
✅ test: all packages pass (including internal/allowlist, internal/imgcache)
✅ binary build: pass
✅ final image: built successfully
```
### Note on Remaining `whitelist` References
There are still `whitelist` references elsewhere in the codebase (config field names like `WhitelistHosts`, the unused `Whitelist` interface in `imgcache.go`, test helper names, error messages). These are all **pre-existing** and outside this PR's scope — the `Whitelist` interface was already dead code on `main` before this PR. A follow-up issue could address a broader rename if desired.
### Verdict: **PASS** ✅
All of sneak's rework feedback addressed. Clean rename, no logic changes, no test weakening, no config modifications. Docker build passes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Extract
HostWhitelist,NewHostWhitelist,IsWhitelisted,IsEmpty, andCountfrominternal/imgcache/into the newinternal/whitelist/package.The whitelist package is completely self-contained, depending only on
net/urlandstringsfrom the standard library. No circular imports introduced.Changes:
whitelist.go→internal/whitelist/whitelist.go(added package comment)whitelist_test.go→internal/whitelist/whitelist_test.go(adapted to external test style)internal/imgcache/service.goto import fromsneak.berlin/go/pixa/internal/whitelistdocker build .passes (lint, tests, build).Part of issue #39
Review: PR #41 — extract whitelist package
Policy Compliance
.golangci.yml,Makefile,Dockerfile,.gitea/workflows/whitelist.gobody identical tomain— onlypackagedeclaration and doc comment changedpackage imgcache) to external (package whitelist_test) — correct for a standalone packageservice.goimportssneak.berlin/go/pixa/internal/whitelistand useswhitelist.HostWhitelist/whitelist.NewHostWhitelistinternal/whitelist/depends only onnet/urlandstrings— zero internal depsinternal/imgcache/whitelist.goandwhitelist_test.gono longer exist// Package whitelist provides host-based URL whitelisting for the image proxy.Requirement Verification
whitelist.gomoved cleanly tointernal/whitelist/with no logic changeswhitelist_test.gomoved withpackage whitelist_test(external test style)service.go)docker build .passes — all tests pass, binary builds successfullyDocker Build
Verdict: PASS ✅
Clean, minimal extraction. No logic changes, no test weakening, no config modifications. Correctly scoped to issue #39.
These stutter. Constructors should be named .New() whenever possible. Also it’s a HostAllowList, not a generic “whitelist”.
eae6f6e9acto469b8bf547Rework: rename to allowlist, fix stuttering
Addressed the review feedback:
internal/whitelist/→internal/allowlist/HostWhitelist→HostAllowListNewHostWhitelist()→New()— usage is nowallowlist.New(...)(no stutter)IsWhitelisted()→IsAllowed()service.go(import, field, constructor call, method call, comments)docker build .passes (fmt, lint, all tests, binary build).Review: PR #41 (post-rework) — allowlist rename
Sneak's Feedback Verification
internal/whitelist/→internal/allowlist/HostWhitelist→HostAllowListNewHostWhitelist()→New()(no stutter)allowlist.New(...)IsWhitelisted()→IsAllowed()allowlist.IsAllowed(...)service.goupdatedPolicy Compliance
.golangci.yml,Makefile,Dockerfile,.gitea/workflows/untouchedpackage allowlist_test) correctallowlist.New(),allowlist.HostAllowList,allowlist.IsAllowed()New()per Go styleguide ("Constructors must be calledNew()")internal/imgcache/whitelist.goandwhitelist_test.godeletedDocker Build
Note on Remaining
whitelistReferencesThere are still
whitelistreferences elsewhere in the codebase (config field names likeWhitelistHosts, the unusedWhitelistinterface inimgcache.go, test helper names, error messages). These are all pre-existing and outside this PR's scope — theWhitelistinterface was already dead code onmainbefore this PR. A follow-up issue could address a broader rename if desired.Verdict: PASS ✅
All of sneak's rework feedback addressed. Clean rename, no logic changes, no test weakening, no config modifications. Docker build passes.