feat: define service interfaces #133

Merged
fuzzy merged 1 commit from feat/service-interfaces into main 2026-08-02 15:12:17 +00:00
Owner

What

Define the four service interfaces, each in its module package:

  • internal/forgejo/service.goForgejoService: CreateRepository (returns clone URL), CreateWebhook (returns webhook ID), ListTags
  • internal/kubernetes/service.goKubernetesService: CreateSiteIngress, PublishSite, CreatePreviewIngress, DeletePreview, DeleteSite
  • internal/git/service.goGitService: Clone, Fetch, Checkout, VerifyAssets
  • internal/site/service.goSiteService: Register, Publish, Rollback plus the RegisterSiteRequest struct

All methods take ctx context.Context first and use the site domain types (site.Site, site.Visibility) to avoid leaking the Forgejo SDK or client-go into service contracts.

Why

Phase 2 task #32 — completes the Core Domain Models and Interfaces phase. These contracts are implemented in Phases 3 (Forgejo/Git), 4 (Kubernetes), 5 (HTTP API), and 7 (rollback).

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; concrete implementations and fakes come in later phases.

Breaking Changes

None.

Notes

  • SiteService.Register takes a full RegisterSiteRequest struct (owner, visibility, custom domain, preview enabled) matching the Phase 5 registration flow.
  • Issues #28–#32 were closed via the Forgejo API as part of this task per the workflow.
  • Phase 2 (Core Domain Models and Interfaces) is now complete.

Closes #28
Closes #29
Closes #30
Closes #31
Closes #32

## What Define the four service interfaces, each in its module package: - **`internal/forgejo/service.go`** — `ForgejoService`: `CreateRepository` (returns clone URL), `CreateWebhook` (returns webhook ID), `ListTags` - **`internal/kubernetes/service.go`** — `KubernetesService`: `CreateSiteIngress`, `PublishSite`, `CreatePreviewIngress`, `DeletePreview`, `DeleteSite` - **`internal/git/service.go`** — `GitService`: `Clone`, `Fetch`, `Checkout`, `VerifyAssets` - **`internal/site/service.go`** — `SiteService`: `Register`, `Publish`, `Rollback` plus the `RegisterSiteRequest` struct All methods take `ctx context.Context` first and use the `site` domain types (`site.Site`, `site.Visibility`) to avoid leaking the Forgejo SDK or client-go into service contracts. ## Why Phase 2 task #32 — completes the Core Domain Models and Interfaces phase. These contracts are implemented in Phases 3 (Forgejo/Git), 4 (Kubernetes), 5 (HTTP API), and 7 (rollback). ## 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; concrete implementations and fakes come in later phases. ## Breaking Changes None. ## Notes - `SiteService.Register` takes a full `RegisterSiteRequest` struct (owner, visibility, custom domain, preview enabled) matching the Phase 5 registration flow. - Issues #28–#32 were closed via the Forgejo API as part of this task per the workflow. - Phase 2 (Core Domain Models and Interfaces) is now complete. Closes #28 Closes #29 Closes #30 Closes #31 Closes #32
feat: define service interfaces
All checks were successful
Test and Release / lint (pull_request) Successful in 3m47s
Test and Release / test (pull_request) Successful in 19m32s
04ea444b00
Define the four service interfaces that orchestrate site lifecycle,
each in its module package:

- internal/forgejo: ForgejoService (repo creation, webhooks, tags)
- internal/kubernetes: KubernetesService (site/preview ingress, publish)
- internal/git: GitService (clone, fetch, checkout, asset verification)
- internal/site: SiteService (register, publish, rollback) with the
  RegisterSiteRequest struct

Interfaces take ctx first and use the site domain types to avoid
leaking the Forgejo SDK or client-go into service contracts. Mark task
done in ROADMAP.md.

closes #28
closes #29
closes #30
closes #31
closes #32
the.auditor left a comment

Review Summary

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

The four service interfaces are well-factored — ctx first everywhere, and the contracts are decoupled from both the Forgejo SDK and client-go by using the site domain types (site.Site, site.Visibility) and plain values (clone URL string, webhook ID int64, tag name slice). Method granularity maps cleanly onto the roadmap phases (Forgejo/Git in 3, Kubernetes in 4, HTTP/rollback in 5/7). RegisterSiteRequest as an explicit struct is the right shape for the Phase 5 registration flow.

No blocking issues.

Non-blocking observations:

  1. RegisterSiteRequest fields have no JSON tags — fine as an internal service-layer type, but the Phase 5 HTTP handler will need JSON binding. Either add tags then or introduce a separate API DTO.
  2. Tag selection logic (task #30 wording) lives outside GitService (only Clone/Fetch/Checkout/VerifyAssets) — expected, since pkg/version owns that in Phase 3. Consistent.

Approving.

## Review Summary Verified locally on the PR head (`04ea444`): `go build`, `go vet`, `gofmt`, `golangci-lint run` all clean; full test suite passes with `-race`. The four service interfaces are well-factored — `ctx` first everywhere, and the contracts are decoupled from both the Forgejo SDK and client-go by using the `site` domain types (`site.Site`, `site.Visibility`) and plain values (clone URL string, webhook ID `int64`, tag name slice). Method granularity maps cleanly onto the roadmap phases (Forgejo/Git in 3, Kubernetes in 4, HTTP/rollback in 5/7). `RegisterSiteRequest` as an explicit struct is the right shape for the Phase 5 registration flow. **No blocking issues.** Non-blocking observations: 1. `RegisterSiteRequest` fields have no JSON tags — fine as an internal service-layer type, but the Phase 5 HTTP handler will need JSON binding. Either add tags then or introduce a separate API DTO. 2. Tag *selection* logic (task #30 wording) lives outside `GitService` (only Clone/Fetch/Checkout/VerifyAssets) — expected, since `pkg/version` owns that in Phase 3. Consistent. Approving.
fuzzy merged commit 04ea444b00 into main 2026-08-02 15:12:17 +00:00
fuzzy deleted branch feat/service-interfaces 2026-08-02 15:12:17 +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!133
No description provided.