feat(tpagectl): implement preview delete subcommand #577
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!577
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/cli-preview-delete"
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
preview deleteend to end: the daemon's missingDELETE /api/v1/sites/{name}/preview/{branch}endpoint plus the tpagectlpreview deletesubcommand.Daemon
DELETE /api/v1/sites/{name}/preview/{branch}handler (#229): owner-scoped (403), calls the existingDeletePreviewservice method, returns 200 with theDeployment, 204 when the preview record is absent, 404 when the site is missing.*branch) so branch names containing slashes (test/*) route correctly; the leading slash is stripped in the handler.CLI
--site(required) plus exactly one of--branchor--all(both or neither → error).Delete preview for site "X"? [y/N](orDelete N previews …for--all) viacmd.Root().Readerunless--force; aborts on no/empty.--all: resolves branches from the previews list, then deletes each./api/v1/sites/{name}/preview/{branch}per branch.Preview "X" for site "Y" deleted./Deleted N preview(s) for site "Y"..--forcesingle branch,--all(list → delete each), confirm-yes, confirm-no abort (no DELETE), 404, missing--site, missing selector, branch+all conflict.Why
Phase 4 roadmap task #231.
Testing
--all/confirmed/declined/404/missing-site/missing-selector/conflictgo test -race ./...passes (19 packages)golangci-lint runcleanBreaking Changes
None.
Notes
The wildcard routing also applies to
preview get(#233), which will use the same*branchpattern. The only remaining preview stub isget.Closes #227
Closes #228
Closes #229
Closes #230
Closes #231
Add the daemon DELETE /api/v1/sites/{name}/preview/{branch} endpoint and the tpagectl preview delete subcommand. Daemon: the handler calls the existing DeletePreview service method, returning 200 with the deployment, 204 when the preview record is absent, 404 when the site is missing. The branch path segment uses a wildcard so branch names containing slashes (test/*) route correctly. CLI: preview delete takes --site plus exactly one of --branch or --all, prompts for confirmation unless --force is given, deletes each selected preview, and prints a confirmation. --all resolves branches from the previews list.Record completion of the tpagectl preview delete subcommand and its daemon endpoint: --site with --branch or --all, confirmation with --force, DELETE /api/v1/sites/{name}/preview/{branch}, and confirmation display. closes #227 closes #228 closes #229 closes #230 closes #231Summary
preview delete: daemonDELETE /api/v1/sites/{name}/preview/{branch}+ tpagectl subcommand. Verified:go test -race ./...passes (19 packages) andgolangci-lint run ./...is clean. Closes #227-231.Verified routing: the gin
*branchwildcard captures slash-containing branches and the handler strips the leading/, sotest/featureround-trips correctly (exercised end-to-end byTestDeletePreviewHandlerOK). The 200/204/404 contract matchesService.DeletePreview(absent record →(nil, nil)→ 204, with the ingress still cleaned; site missing → 404).No blocking issues.
Suggestions (filed as issues)
internal/httpapi/sites.go(deletePreview) – the 204 branch (d == nil→ NoContent) is untested; handler tests cover only 200 and 404. Filed as #578References (covered by existing issues)
confirmDeletePreviewsis a fourth confirmation-prompt copy (#565); non-404 passthrough remains untested (#571).Praise
preview get--branch/--allmutual exclusion and required-selector validation--allresolves branches from the previews list; confirmation UX mirrorssite delete--all/confirm/decline/404/missing-site/missing-selector/conflict)