feat(tpagectl): add context support for multiple instances #629
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!629
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tpagectl-context"
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 multi-instance support (roadmap #319), the final CLI-ROADMAP item.
contextsmap (name → {url, token}) plus an activecontextkey.config.ApplyContextresolves a named context intoserver.url/server.token(unknown context → config error, exit 2);config.SetActiveContext(name)persists the active name via the existing atomic 0600 config write.--contextflag +contextcommand (#317) —--context NAMEselects a context for a single invocation (precedence:--server/--tokenflags > selected context >server.*defaults > configcontext).internal/tpagectl/contextgroup:context list(NAME/URL/ACTIVE table, active marked*) andcontext use NAME(validates the name against the configuredcontexts, then persists it).Why
Roadmap task #319 — completing the entire
CLI-ROADMAP.md.Testing
contexts+ active parsing;ApplyContextknown/unknown + token-only merge;SetActiveContextwrite → Load round-trip (XDG temp)--context prodresolves URL/token; activecontext:from config applied;--serveroverrides context; unknown context → exit 2context listtable (NAME/URL/ACTIVE +*);context usepersists and round-trips; unknown name and missing arg → validation errorscontext --helpwiring; root-help golden + docs regeneratedgo test -race ./...passes (36 packages);make coverage= 84.9% (≥80% gate)golangci-lint runclean; pre-commit hooks passBreaking Changes
None. Adds a
contextcommand group, a root--contextflag, and newcontexts/contextconfig keys (additive).Notes
No
thwap-actionsaction applies (CLI feature). This closes out the CLI roadmap (all phases 1–10 complete).Closes #317
Closes #318
Closes #319
Support multiple thwap-pagesd instances: - config: new `contexts` map (name -> {url, token}) and an active `context` key; config.ApplyContext resolves a named context into server.url/token (unknown context -> error), and SetActiveContext persists the active name via the atomic 0600 config write. - Root --context NAME selects a context for a single invocation (flag > config context > server defaults; --server/--token still win). - New `context` command group: `context list` (NAME/URL/ACTIVE table) and `context use NAME` (validates the name and persists it). Documented in the README and regenerated command docs. Closes #317 Closes #318 Closes #319Clean multi-instance support that closes out the CLI roadmap. The
contexts/contextconfig keys,ApplyContextmerge semantics,SetActiveContextpersistence via the existing atomic 0600 write, root--contextflag, andcontext list/usegroup are all implemented cleanly with good tests and regenerated docs. Approving; two findings filed.Suggestions
cmd/tpagectl/main.go–ApplyContextruns afterconfig.Load, overwritingcfg.Server.URL/Tokenthat viper already set fromTPAGECTL_SERVER_URL/TPAGECTL_SERVER_TOKEN, so an active context (a config-file value) silently beats the documented env-above-file precedence. Apply context only when the env var didn't set the field, or document the new precedence. Filed as #630.internal/tpagectl/context/context.go:84–context usechecksURL == ""rather than map membership, rejecting token-only contexts thatApplyContextexplicitly supports, and an unknown context exits 5 viausevs 2 via--context— inconsistent classification. Check membership and align exit codes. Filed as #631.Praise
--server/--tokenflags > selected context >server.*defaults) is correctly ordered and tested.context listsorts names and marks the active one with*using the sharedoutput.RenderTable.SetActiveContextreuses the atomic 0600 config writer, keeping the token-file security posture consistent.