feat(cmd): --json on domains list and domains stats - #123
Merged
Conversation
omitempty is a no-op on time.Time, so an uncertified registered host reported expires_at as 0001-01-01 and an unpolled source did the same for fetched_at. omitzero drops them, which matters now that the struct is about to become a machine-readable CLI surface. Refs #121
The gem's dash doctor needs hold state (until/kind) without scraping the table. list --json emits DomainsStatusResponse verbatim so the RPC struct is the one contract; stats --json emits a CLI-side summary folded from the same response. Tables stay the default. Closes #121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
domains list --jsonemitsserver.DomainsStatusResponseverbatim (internal/cmd/domains.go) — the RPC struct is the one contract, no CLI-only copy.domains stats --jsonemits a CLI-sideDomainsStatsSummaryfolded from the same response; the text output now prints from the same fold.expires_at/fetched_attags switched fromomitempty(no-op ontime.Time) toomitzero(internal/server/commands.go) so uncertified hosts stop reporting a year-0001 expiry.fetchDomainsStatuscallback now returnserrorso a marshal failure propagates.Tables remain the default. The "dynamic domains are not enabled" RPC error stays a non-zero exit in JSON mode — the gem degrades on exit status.
Closes #121
Test plan
TestDomainsStatusResponse_JSONOmitsZeroTimes— zero times omitted, real ones emittedTestDomainsListCommand_JSONFlag/TestDomainsStatsCommand_JSONFlag— flag present, default falseTestDomainsListCommand_JSONOutputShape—quarantine.<domain>.{until,failures,kind},held_removals,registered.<host>.serviceTestSummarizeDomains(table-driven) +TestDomainsStatsSummary_JSONKeysgo test -count=1 ./...×3 green,gofmt -lempty,go vetclean,make buildokdash-proxy domains list --jsonagainst a running proxy; gem follow-up in../kamalafter a tagged image shipsDeviations & judgment calls
make lintpanics on the cleanmaintree too — the locally installed golangci-lint v2.11.3 was built with go1.26 while a dependency now requires go1.27 (file requires newer Go version go1.27). Not caused by this change; CI's lint run is the gate. Not fixed here.printJSONis a small shared helper indomains.gorather than duplicatinglistCommand.displayJSONa third time;list.gois left untouched to keep the diff local.DomainsStatsSummarylives ininternal/cmd(exported so the type is nameable in docs), notinternal/server— it is a presentation fold, not an RPC payload.make testrun reported FAIL with no visible failing test in the truncated output; three subsequentgo test -count=1 ./...runs were clean. Treated as a pre-existing flake, not investigated further.Summary by cubic
Adds
--jsontodomains listanddomains statsso scripts and thedashgem can read domain status without scraping tables. Closes #121.domains list --jsonemits the RPC response verbatim;domains stats --jsonemits a newDomainsStatsSummaryfolded from the same response.time.Timefields (expires_at,fetched_at) switched toomitzeroso uncertified hosts stop reporting a year-0001 expiry.fetchDomainsStatusnow propagates JSON marshal errors.Written for commit cf91808. Summary will update on new commits.