feat(tpagectl): implement site update subcommand #558
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!558
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/cli-site-update"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implements
site updateend to end: the daemon's missingPATCH /api/v1/sites/{name}endpoint plus the tpagectlsite updatesubcommand. This completes the Phase 2 site command group.Daemon
UpdateSiteRequest(pointer fields for partial updates: visibility, custom domain, preview-enabled) +SiteService.Update— 404 for unknown sites, validates changed fields, re-creates the site Ingress viaCreateSiteIngresswhen the custom domain changes, persists viasites.Update.validateRequest(validateVisibility,validateCustomDomain) and reused.PATCH /api/v1/sites/{name}handler: owner-scoped (403), invalid body/validation (400), 404, 200 with the updated site.CLI
site update SITEwith optional--visibility,--domain(empty clears),--preview-enabled(IsSettri-state) — #188/#189.site "X" not found.--preview-enabled=false, validation, nothing-to-update, 404, missing arg.errNotImplementedsentinel and its test are removed.Why
Phase 2 roadmap task #192; the final site command.
Testing
go test -race ./...passes (17 packages)golangci-lint runcleanBreaking Changes
None.
SiteServicegainsUpdate;Sitesemantics unchanged.Notes
Visibility updates are record-only: the gitea SDK's
EditRepoOptioncan only express a binaryPrivateflag and cannot representlimitedrepo visibility, so the backing repository's visibility is not changed. Custom domain changes do re-provision the Ingress so the new host serves the site.Closes #188
Closes #189
Closes #190
Closes #191
Closes #192
Add the daemon PATCH /api/v1/sites/{name} endpoint and the tpagectl site update subcommand. Daemon: SiteService.Update applies partial updates to visibility, custom domain, and preview-enabled, re-creating the site Ingress when the custom domain changes. The handler is owner-scoped and returns 200 with the updated site, 400 on validation, 403 when unauthorized, 404 when missing. Visibility updates are record-only (the gitea SDK cannot express 'limited' repo visibility). CLI: site update takes a required site name and optional --visibility/--domain/--preview-enabled flags, fetches the current site, issues the PATCH, and prints a before/after diff of the changed fields. A 404 surfaces as a friendly not-found error. All site subcommands are now implemented, so the stub sentinel and its test are removed.Record completion of the tpagectl site update subcommand and its daemon endpoint: positional site name, visibility/domain/preview-enabled updates, PATCH /api/v1/sites/{name}, and before/after diff display. This completes the Phase 2 site command group. closes #188 closes #189 closes #190 closes #191 closes #192Summary
site update: daemonPATCH /api/v1/sites/{name}+ tpagectlsite update, completing the Phase 2 site command group. Verified:go test -race ./...passes (17 packages) andgolangci-lint run ./...is clean. Closes #188-192.Verified behavior:
updateRequestmirrorsUpdateSiteRequest(pointer fields, identical JSON keys);CreateSiteIngressis create-or-update (TestCreateSiteIngressUpdate), so domain changes upsert the site's single ingress in place — no orphaned old-domain ingress.No blocking issues.
Suggestions (filed as issues)
internal/site/service.go:456– visibility updates are record-only: the Forgejo repo's actual visibility is not changed (SDKEditRepoOptioncan't expresslimited), sosite update --visibility privatereports success while repo access is unchanged. Filed as #559internal/site/service.go:477– ingress is re-provisioned on anyCustomDomain != nil, even a no-op domain change. Filed as #560internal/tpagectl/site/update.go–friendlyNotFoundhelper is extracted butget.go/delete.gostill inline the same 404 mapping. Filed as #561Praise
validateVisibility/validateCustomDomain) reused by registerIsSettri-state handling for--preview-enabledis correct, including--preview-enabled=false(no changes)caseerrNotImplementedremoval tidily completes the group