feat(site): define repository interfaces #132

Merged
fuzzy merged 1 commit from feat/repository-interfaces into main 2026-08-02 14:03:22 +00:00
Owner

What

Define the repository interfaces in internal/site/interfaces.go:

  • SiteRepositoryCreate, Get, List, Update, Delete (sites keyed by name)
  • DeploymentRepositoryCreate, Get, ListBySite, Update, Delete (deployments keyed by composite (siteName, version))
  • All methods take ctx context.Context first and return errors via the centralized package
  • Add ErrNotFound sentinel to errors/errors.go — documented as the error Get/Update/Delete return when a resource is absent

Why

Phase 2 task #27 — the persistence contracts that concrete repository implementations (Phase 4/7) and services (#32) depend on.

Testing

  • go build ./...
  • go vet ./...
  • go test -race ./... — passes
  • gofmt -l ./cmd ./internal clean
  • golangci-lint run — 0 issues
  • pre-commit hooks all pass

Interfaces have no behavior to unit test; fakes come with concrete implementations in later phases.

Breaking Changes

None.

Notes

  • The errors package is named the same as stdlib errors; files importing both should alias the project package (e.g. apperrors).
  • Issues #25–#27 were closed via the Forgejo API as part of this task per the workflow.

Closes #25
Closes #26
Closes #27

## What Define the repository interfaces in `internal/site/interfaces.go`: - **`SiteRepository`** — `Create`, `Get`, `List`, `Update`, `Delete` (sites keyed by name) - **`DeploymentRepository`** — `Create`, `Get`, `ListBySite`, `Update`, `Delete` (deployments keyed by composite `(siteName, version)`) - All methods take `ctx context.Context` first and return errors via the centralized package - Add `ErrNotFound` sentinel to `errors/errors.go` — documented as the error `Get`/`Update`/`Delete` return when a resource is absent ## Why Phase 2 task #27 — the persistence contracts that concrete repository implementations (Phase 4/7) and services (#32) depend on. ## Testing - [x] `go build ./...` - [x] `go vet ./...` - [x] `go test -race ./...` — passes - [x] `gofmt -l ./cmd ./internal` clean - [x] `golangci-lint run` — 0 issues - [x] pre-commit hooks all pass Interfaces have no behavior to unit test; fakes come with concrete implementations in later phases. ## Breaking Changes None. ## Notes - The `errors` package is named the same as stdlib `errors`; files importing both should alias the project package (e.g. `apperrors`). - Issues #25–#27 were closed via the Forgejo API as part of this task per the workflow. Closes #25 Closes #26 Closes #27
feat(site): define repository interfaces
All checks were successful
Test and Release / lint (pull_request) Successful in 3m45s
Test and Release / test (pull_request) Successful in 19m34s
cd9ac0dda1
Define SiteRepository and DeploymentRepository CRUD interfaces in the
internal/site package. Sites are keyed by name; deployments by the
composite (siteName, version) key. Add the ErrNotFound sentinel to
the centralized errors package, documented as the error returned by
Get, Update, and Delete when a resource is absent. Mark task done in
ROADMAP.md.

closes #25
closes #26
closes #27
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-02 13:13:21 +00:00
the.auditor left a comment

Review Summary

Verified locally on the PR head (cd9ac0d): go build, go vet, gofmt, golangci-lint run all clean; full test suite passes with -race.

Interface contracts are clean and well-documented — ctx first on all methods, consistent CRUD shape, and the (siteName, version) composite key for deployments is a sensible choice that sidesteps the missing-ID concern from the previous review. ErrNotFound sentinel in the centralized errors package is the right hook for Get/Update/Delete semantics.

No blocking issues.

Non-blocking observations:

  1. package errors importing stdlib errors compiles fine and lints clean, but it's a subtle footgun — files that need both should alias the project package (e.g. apperrors) as the PR notes. Consider reserving errors/errors.go for the sentinels only and letting callers alias.
  2. Get returns *Site while List returns []Site (value slice) — minor signature asymmetry; fine as-is.

Approving.

## Review Summary Verified locally on the PR head (`cd9ac0d`): `go build`, `go vet`, `gofmt`, `golangci-lint run` all clean; full test suite passes with `-race`. Interface contracts are clean and well-documented — `ctx` first on all methods, consistent CRUD shape, and the `(siteName, version)` composite key for deployments is a sensible choice that sidesteps the missing-ID concern from the previous review. `ErrNotFound` sentinel in the centralized `errors` package is the right hook for `Get`/`Update`/`Delete` semantics. **No blocking issues.** Non-blocking observations: 1. `package errors` importing stdlib `errors` compiles fine and lints clean, but it's a subtle footgun — files that need both should alias the project package (e.g. `apperrors`) as the PR notes. Consider reserving `errors/errors.go` for the sentinels only and letting callers alias. 2. `Get` returns `*Site` while `List` returns `[]Site` (value slice) — minor signature asymmetry; fine as-is. Approving.
fuzzy merged commit cd9ac0dda1 into main 2026-08-02 14:03:22 +00:00
fuzzy deleted branch feat/repository-interfaces 2026-08-02 14:03:23 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!132
No description provided.