refactor: rename whitelist package to allowlist, fix stuttering
All checks were successful
check / check (push) Successful in 1m1s

- Rename internal/whitelist/ → internal/allowlist/
- Rename type HostWhitelist → HostAllowList
- Rename constructor NewHostWhitelist() → New()
- Rename method IsWhitelisted() → IsAllowed()
- Update all imports and references in service.go

No logic changes — purely naming improvements per review feedback.
This commit is contained in:
user
2026-03-24 18:34:50 -07:00
parent f96c4a514e
commit 469b8bf547
3 changed files with 30 additions and 30 deletions

View File

@@ -11,8 +11,8 @@ import (
"time"
"github.com/dustin/go-humanize"
"sneak.berlin/go/pixa/internal/allowlist"
"sneak.berlin/go/pixa/internal/imageprocessor"
"sneak.berlin/go/pixa/internal/whitelist"
)
// Service implements the ImageCache interface, orchestrating cache, fetcher, and processor.
@@ -21,7 +21,7 @@ type Service struct {
fetcher Fetcher
processor *imageprocessor.ImageProcessor
signer *Signer
whitelist *whitelist.HostWhitelist
allowlist *allowlist.HostAllowList
log *slog.Logger
allowHTTP bool
maxResponseSize int64
@@ -86,7 +86,7 @@ func NewService(cfg *ServiceConfig) (*Service, error) {
fetcher: fetcher,
processor: imageprocessor.New(imageprocessor.Params{MaxInputBytes: maxResponseSize}),
signer: signer,
whitelist: whitelist.NewHostWhitelist(cfg.Whitelist),
allowlist: allowlist.New(cfg.Whitelist),
log: log,
allowHTTP: allowHTTP,
maxResponseSize: maxResponseSize,
@@ -382,7 +382,7 @@ func (s *Service) Stats(ctx context.Context) (*CacheStats, error) {
// ValidateRequest validates the request signature if required.
func (s *Service) ValidateRequest(req *ImageRequest) error {
// Check if host is whitelisted (no signature required)
// Check if host is allowed (no signature required)
sourceURL := req.SourceURL()
parsedURL, err := url.Parse(sourceURL)
@@ -390,11 +390,11 @@ func (s *Service) ValidateRequest(req *ImageRequest) error {
return fmt.Errorf("invalid source URL: %w", err)
}
if s.whitelist.IsWhitelisted(parsedURL) {
if s.allowlist.IsAllowed(parsedURL) {
return nil
}
// Signature required for non-whitelisted hosts
// Signature required for non-allowed hosts
return s.signer.Verify(req)
}