feat(tpagectl): add watch command #624
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!624
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tpagectl-watch"
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 Phase 10
watchcommand (roadmap #310).internal/tpagectl/watchpackage —tpagectl watch SITEpolls the site status endpoint (GET /api/v1/sites/{name}, whose payload already carriescurrent_deployment) every--interval(default2s); the daemon exposes no SSE endpoint, so polling is used (#307).New production deployment: …notification, colored success on a terminal.--oncechecks once and exits (scripting/CI); Ctrl-C (ctx cancel) stops cleanly; a 404 yields the friendly not-found error; transient poll errors are reported and retried.--site, with the interactive fuzzy picker when omitted on a terminal.docs/commands/tpagectl-watch.*and the root-help golden regenerated.Why
Roadmap task #310, the first item in Phase 10.
Testing
deploymentChanged(nil/same/version/commit/status transitions),formatDeploymentwatch --onceprints the current deployment; a fake server returning v1 then v2 produces theNew production deployment: v2.0.0line (short interval + canceled ctx); 404 → friendly not-found errorwatch --helpwiring via the root commandgo test -race ./...passes (32 packages);make coverage= 84.7% (≥80% gate)golangci-lint runclean; pre-commit hooks passBreaking Changes
None. Adds a
watchcommand.Notes
No
thwap-actionsaction applies (CLI feature). Polling is used because the daemon has no events/SSE endpoint.Closes #307
Closes #308
Closes #309
Closes #310
Clean, focused
watchcommand. Polling fits the daemon's API (no SSE), 404 maps to the friendly not-found error, transient failures are reported and retried,--once/--intervalare present with a sane guard on non-positive intervals, and change detection across version/commit/status/deployed-at is correct with the notification colored success. Tests cover the core paths. Approving; one--oncesemantics issue filed.Suggestions
internal/tpagectl/watch/watch.go:121–watch SITE --oncereturns nil even when the poll failed (non-404 5xx/network errors printwatch: ...then fall through toreturn nil). For the documented scripting/CI use of--once, a failed check should exit non-zero — return the last poll error. Filed as #625.Notes
New production deployment: none— a removal, not a new deployment; wording is slightly off but harmless.ctx.Done()path only fires in the canceled-ctx test — practically fine.Praise
deploymentChangedcorrectly handles nil transitions (none → v1 and v1 → none both detected).interval <= 0guard prevents a tight-loop DoS from a bad flag.interactive.ResolveSiteandui.Success, keeping the command consistent with the rest of the CLI.