feat(ca/acme/eab): add --json output to add, list, and remove#1663
Draft
joshdrake wants to merge 1 commit into
Draft
feat(ca/acme/eab): add --json output to add, list, and remove#1663joshdrake wants to merge 1 commit into
joshdrake wants to merge 1 commit into
Conversation
The `step ca acme eab` subcommands only emitted fixed-width column text,
making them awkward to script against (add.go even carried a standing
TODO asking for JSON output). Add a `--json` flag to each subcommand for
machine-readable output:
- add: marshals the created key (including the secret) as a JSON object
- list: collects all pages into a JSON array, bypassing $PAGER; the
secret HMAC key is omitted, matching the table's masking
- remove: emits {"provisioner","id","deleted":true} on success
The shared cliEAK struct now has exported, JSON-tagged fields, and toCLI
guards createdAt with an IsZero check (mirroring boundAt) so unset
timestamps are dropped via omitempty. Adds the first unit tests for the
package covering toCLI and the JSON contract.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
1 similar comment
|
|
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
Adds a
--jsonflag for machine-readable output across the entirestep ca acme eabcommand chain (add,list,remove). Previously these subcommands only emitted fixed-width column text, making them awkward to script against —add.goeven carried a standing// TODO(hs): JSON output, so that executing this command can be more easily automated?.What changed (
command/ca/acme/eab/)eab.go— ExportedcliEAK's fields with JSON tags (id,provisioner,reference, plusomitemptykey/createdAt/boundAt/account). GuardedcreatedAtwith anIsZero()check mirroring the existingboundAthandling so unset timestamps drop out viaomitempty. Added a shared package-localjsonFlag.add.go—--jsonmarshals the created key including the secret (the whole point ofadd) as a JSON object; replaced theTODO(hs).list.go—--jsoncollects every page into a JSON array and bypasses the$PAGERmachinery. The secret HMAC key is omitted, matching the table's existing*****masking; an empty result is[].remove.go—--jsonemits{"provisioner":…,"id":…,"deleted":true}on success.eab_test.go— New; the package's first tests, coveringtoCLI(including zero-timestamp handling) and the JSON contract for both the add and list shapes.Example output
Design decisions
list --jsonomits the key rather than exposing every secret in bulk — this preserves today's posture where onlyadd(at creation time) ever reveals a key.Testing
go build ./...,gofmt, andgo vetclean.golangci-lintwith the smallstep config → 0 issues.--jsonverified present in--helpfor all three subcommands.🤖 Generated with Claude Code