GeezerVison is showing github.com — feat(ca/acme/eab): add --json output to add, list, and remove by joshdrake · Pull Request #1663 · smallstep/cli
Conversation
Summary
Adds a --json flag for machine-readable output across the entire step ca acme eab command chain (add, list, remove). Previously these subcommands only emitted fixed-width column text, making them awkward to script against — add.go even 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 — Exported cliEAK's fields with JSON tags (id, provisioner, reference, plus omitempty key/createdAt/boundAt/account). Guarded createdAt with an IsZero() check mirroring the existing boundAt handling so unset timestamps drop out via omitempty. Added a shared package-local jsonFlag.
add.go — --json marshals the created key including the secret (the whole point of add) as a JSON object; replaced the TODO(hs).
list.go — --json collects every page into a JSON array and bypasses the $PAGER machinery. The secret HMAC key is omitted, matching the table's existing ***** masking; an empty result is [].
remove.go — --json emits {"provisioner":…,"id":…,"deleted":true} on success.
eab_test.go — New; the package's first tests, covering toCLI (including zero-timestamp handling) and the JSON contract for both the add and list shapes.
Example output
// add --json
{
"id": "zFGdKC1sHmNf3Wsx3OujY808chxwEdmr",
"provisioner": "my_acme",
"reference": "my_ref",
"key": "Zm9vYmFyYmF6..."
}
// list --json (key omitted, matching the masked table)
[
{
"id": "zFGdKC1sHmNf3Wsx3OujY808chxwEdmr",
"provisioner": "my_acme",
"createdAt": "2026-07-06 12:00:00 +00:00",
"reference": "my_ref"
}
]
// remove --json
{
"provisioner": "my_acme",
"id": "zFGdKC1sHmNf3Wsx3OujY808chxwEdmr",
"deleted": true
}
Design decisions
list --json omits the key rather than exposing every secret in bulk — this preserves today's posture where only add (at creation time) ever reveals a key.
- All three subcommands get the flag for a consistent chain.
Testing
go build ./..., gofmt, and go vet clean.
golangci-lint with the smallstep config → 0 issues.
- New unit tests pass;
--json verified present in --help for all three subcommands.
- Not exercised against a live Certificate Manager CA (requires admin credentials); the JSON shape is covered by the unit tests instead.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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) <[email protected]>
|
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You have signed the CLA already but the status is still pending? Let us recheck it.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
1 similar comment
|
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You have signed the CLA already but the status is still pending? Let us recheck it.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
hslatman
Awaiting requested review from hslatman
At least 1 approving review is required to merge this pull request.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
needs triage
Waiting for discussion / prioritization by team
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|