feat(tpagectl): implement site list subcommand #551
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!551
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/cli-site-list"
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 listend to end: the daemon's missingGET /api/v1/sitesendpoint plus the tpagectlsite listsubcommand.Daemon
SiteService.Listreturns all sites with their current deployments;SiteStatusgains aurlfield populated via the newKubernetesClient.SiteURL.GET /api/v1/siteshandler returns[]SiteStatus, scoped to the authenticated user's sites (admins see all; no-auth daemons return all).List(deployments + URLs), handler list/error/owner-scoping.CLI
site listfetches/api/v1/sitesand renders a table of Name, Owner, Status, Domain, URL (text/tabwriter).--format(table default, json, yaml) — #199;gopkg.in/yaml.v3promoted to a direct dependency.--filter owner=<name>and/or--filter status=<status>(repeatable) — #175.Why
Phase 2 roadmap task #176. The daemon had no site-list endpoint, so this delivers the CLI command and its prerequisite API together.
Testing
go test -race ./...passes (17 packages)golangci-lint runcleanBreaking Changes
None.
SiteStatusgains an optionalurlJSON field (omitempty).Notes
#199(--format) is also referenced bydeployment list(#200); the implementation here is reusable there later.Closes #172
Closes #173
Closes #175
Closes #176
Closes #199
Summary
Site list: daemon
GET /api/v1/sites+ tpagectlsite list. Verified:golangci-lint run ./...clean; full-suitego test -race ./...passes intermittently —internal/sitefails under repeated runs. Closes #172/#173/#175/#176/#199.Blocking Issues
internal/site/service_test.go:468(TestList) +service.go:343(List) – non-deterministic ordering.MemoryRepository.List(memory.go:51) iterates a map, soService.List/handler return sites in random order.TestListassumes insertion order and is flaky — reproduced withgo test -race ./internal/site/... -count=5: This also makesGET /api/v1/sitesandsite listoutput nondeterministic. Suggested fix: sort sites deterministically (e.g. by name) in the repositoryListorService.List, and make the test order-independent.Suggestions (filed as issues)
internal/tpagectl/site/list.go:49–--format yamlkeys diverge from JSON/API keys (repourl,customdomain,currentdeployment,previewenabled,createdat) because the structs only carryjson:tags. Filed as #552Praise
[]notnull--format/--filterimplementation with a reusable filter pipelineyaml.v3correctly promoted to a direct dependency, no new modulesAddressed the requested changes.
Blocking (non-deterministic ordering):
Service.Listnow sorts sites by name, soGET /api/v1/sitesandsite listoutput is deterministic.TestListis order-independent (looks up sites by name). Verified withgo test -race -count=5 ./internal/site/.Also fixed (filed as #552): added
yaml:tags to the site list response structs so--format yamlemits snake_case keys matching the JSON/API payload (repo_url,custom_domain,current_deployment, …);TestListYAMLnow assertsrepo_url:/current_deployment:.Verified:
go test -race ./...(17 packages),golangci-lint run, and pre-commit all pass.Summary
Re-review after the fix commits. Verified:
go test -race ./...passes (17 packages),golangci-lint run ./...clean, and the previously-flakyinternal/sitesuite passes consistently under-count=5. Closes #172/#173/#175/#176/#199.Blocking Issues
Resolved.
Service.Listnow sorts statuses by name, makingGET /api/v1/sitesandsite listoutput deterministic.TestListis order-independent (looks up sites by name). Reproduced the prior flake withgo test -race -count=5 ./internal/site/before the fix; it is stable now.Previously Filed Suggestions
yaml:tags added tolistResponse/listDeployment;TestListYAMLnow assertsrepo_url:andcurrent_deployment:.Praise
yaml:tags mirror JSON tags exactly, keeping format keys consistent--formatflag (table, json, yaml) #174