GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add JSON output to coder provisioner keys create by nickvigilante · Pull Request #30152 · coder/coder

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Sep 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Uses the cliui output helpers from #30508.

coder provisioner keys create printed the new key's secret as prose, so scripts provisioning external provisioners had to scrape it and look up the key's ID and tags separately.

It now accepts -o text|json.
JSON is the key as provisioner keys list shows it (ID, name, organization, tags, created at) plus the one-time key.

Behavior change: Additive.
Default text output is unchanged.
The command now fetches the new key's metadata with the returned secret (GET /api/v2/provisionerkeys/{key}). If that fails, it prints a warning to stderr, falls back to the name, organization and tags it sent (leaving id and created_at unset), and still outputs the secret.

Decisions
  • CreateProvisionerKey only returns the secret, so the key's metadata comes from GetProvisionerKey(secret), the same lookup coder provisioner start uses. This replaced an earlier list-and-match-by-name approach, per review.
  • A failed lookup never fails the command, because the key already exists and the secret can't be shown again.

Closes CLI-36

This PR was generated by Coder Agents on behalf of @nickvigilante.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@linear-code

linear-code Bot commented Sep 30, 2026

Copy link
Copy Markdown

CLI-36

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned nickvigilante Sep 30, 2026
@nickvigilante
nickvigilante marked this pull request as ready for review September 30, 2026 00:43
@nickvigilante
nickvigilante requested a review from matifali September 30, 2026 00:43
@matifali Linear Code

matifali commented Sep 30, 2026

Copy link
Copy Markdown
Member

I think its fine most secrets print only text like coder sceret create as it can then be piped to otehr programs coder secret create | or diected to files coder secret create > secret.txt

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nickvigilante

nickvigilante commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@matifali Thanks for the review. Do you have any suggested changes for the PR, or are we good to merge?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nickvigilante nickvigilante added the cli Area: CLI label Oct 5, 2026
@nickvigilante
nickvigilante requested a review from jeremyruppel October 6, 2026 14:23
@jeremyruppel

jeremyruppel commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

I noticed a bunch of duplication in these PRs, particularly the json/table formatting

  • feat: add JSON output to coder provisioner keys create #30152 (this one)
  • feat: add JSON output to coder tokens create #30135
  • feat: add JSON output to coder ai-gateway keys create #30139
  • feat: add output formats to coder organizations members edit-roles #30145

DRYing this up would probably go a long way for making these PRs smaller, and would set a pattern for future json/table output. I suggest asking the agent to create a new, first PR that sets up and tests some formatting helpers, then each of these callsites can be stacked on top of it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nickvigilante

nickvigilante commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@jeremyruppel Agree on DRYing it up. I wanted to originally do a global -o flag, but I think coder config-ssh currently uses -o for something not related to output (I think it's for SSH options), so I couldn't do it at the root level without introducing that breaking change. I'll see if there's a compromise though!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nickvigilante nickvigilante mentioned this pull request Oct 8, 2026
feat(cli/cliui): add TextFormatFunc and OutputFormatter.WriteLine helpers #30508
Merged
@matifali
matifali removed their request for review October 8, 2026 15:22
@nickvigilante
nickvigilante force-pushed the vigilante/cli-36-coder-provisioner-keys-create-add-o-output-with-json branch from d40e3ff to c7b78f3 Compare October 8, 2026 15:45
@nickvigilante
nickvigilante changed the base branch from main to vigilante/cli-56-cliui-add-shared-text-formatter-and-write-helpers-for-o October 8, 2026 15:45
@nickvigilante
nickvigilante requested a review from matifali October 8, 2026 15:45
@nickvigilante
nickvigilante force-pushed the vigilante/cli-36-coder-provisioner-keys-create-add-o-output-with-json branch from c7b78f3 to b3efc89 Compare October 8, 2026 18:23
jeremyruppel
jeremyruppel reviewed Oct 8, 2026
View reviewed changes

@jeremyruppel jeremyruppel left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default text output is byte-identical to before, and TestProvisionerKeys passes locally. A few notes inline.

One broader question: did you consider fixing this in the API instead? postProvisionerKey already has the ID, created-at, and tags in params but only returns {key}. Adding those to CreateProvisionerKeyResponse would remove the extra list call, the race between create and list, and the zero-valued fallback below. It touches the SDK, API docs, and generated types, so a follow-up is a reasonable answer, but the CLI workaround exists only because of that gap.

Note

This review was generated by Coder Agents on behalf of @jeremyruppel.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread enterprise/cli/provisionerkeys.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread enterprise/cli/provisionerkeys.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread enterprise/cli/provisionerkeys.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@nickvigilante

nickvigilante commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@jeremyruppel I hadn't considered updating the API here, but I'll happily do that if it cuts out a race condition. Stay tuned, another PR incoming!

jeremyruppel reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nickvigilante added a commit that referenced this pull request Oct 8, 2026
@nickvigilante
feat(cli/cliui): add TextFormatFunc and OutputFormatter.WriteLine hel…
0efb574
…pers (#30508)

Adds two small helpers to `cli/cliui/output.go` so commands that add
`-o/--output` don't repeat the same boilerplate, as suggested in
#30152 (comment) by
@jeremyruppel.

- `TextFormatFunc[T]` wraps `ChangeFormatterData(TextFormat(), ...)`
with the type assertion and "expected X, got Y" error, so a command only
supplies its render function.
- `(*OutputFormatter).WriteLine` formats data and writes it to an
`io.Writer` with a trailing newline, replacing the `Format` + `Fprintln`
block.

No existing callers change in this PR. These PRs are stacked on it and
use the helpers:

- #30135 `coder tokens create`
- #30139 `coder ai-gateway keys create`
- #30145 `coder organizations members edit-roles`
- #30152 `coder provisioner keys create`

Migrating the existing callers on `main` (for example
`cli/organization.go`, `enterprise/cli/workspaceproxy.go`) is left for a
follow-up, since some of them print with `Fprint` rather than `Fprintln`
and need care to keep output identical.

Refs CLI-56

<details>
<summary>Decision log</summary>

- A global `-o` flag on the root command was ruled out because `coder
config-ssh` already uses `-o` for `--ssh-option`.
- The "one-time secret plus metadata" response structs in #30135 and
#30152 stay local to each command, since they embed different SDK types
and a shared helper would save little.
- `WriteLine` uses `Fprintln` to match the four stacked PRs and most
existing callers.
It was renamed from `Write` during review so the trailing newline is
visible at call sites and the method is not confused with `io.Writer`.

</details>

> [!NOTE]
> This PR was generated by Coder Agents on behalf of @nickvigilante.
Base automatically changed from vigilante/cli-56-cliui-add-shared-text-formatter-and-write-helpers-for-o to main October 8, 2026 19:41
@nickvigilante
nickvigilante requested a review from jeremyruppel October 14, 2026 16:09
@nickvigilante
nickvigilante force-pushed the vigilante/cli-36-coder-provisioner-keys-create-add-o-output-with-json branch from 4ebc13b to e17dd34 Compare October 16, 2026 18:36
@nickvigilante
nickvigilante requested a review from untra October 16, 2026 19:36
untra
untra reviewed Oct 16, 2026
View reviewed changes
Comment thread enterprise/cli/provisionerkeys.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@nickvigilante
nickvigilante requested a review from untra October 20, 2026 22:56
@github-actions github-actions Bot added the stale This issue is like stale bread. label Nov 7, 2026
@github-actions github-actions Bot closed this Nov 10, 2026
@nickvigilante nickvigilante removed the stale This issue is like stale bread. label Nov 10, 2026
@nickvigilante nickvigilante reopened this Nov 10, 2026
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 16:54 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 16:54 — with GitHub Actions Inactive
@nickvigilante

nickvigilante commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@untra Can I poke you for another review?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@untra

untra commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

poke me again once the light is green plz

nickvigilante reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nickvigilante and others added 7 commits November 11, 2026 00:08
@nickvigilante
feat: add JSON output to coder provisioner keys create
efdd565
`coder provisioner keys create` printed the new key's secret as prose,
so scripts provisioning external provisioners had to scrape it and look
up the key's ID and tags separately.

Linear: CLI-36
@nickvigilante
refactor: use cliui.TextFormatFunc and OutputFormatter.Write
500b1a5
@nickvigilante
refactor: use cliui.OutputFormatter.WriteLine
2a8faa4
@nickvigilante @jeremyruppel
Update enterprise/cli/provisionerkeys.go
fda3156
Co-authored-by: Jeremy Ruppel <[email protected]>
@nickvigilante
fix(enterprise/cli): report missing provisioner key metadata
d0ef38b
When the metadata lookup after create fails or finds no matching key,
fall back to the tags this command sent and warn on stderr in both
cases, instead of only when the list call errors.
@nickvigilante
refactor(enterprise/cli): fetch created provisioner key by secret
f7ac914
Use GetProvisionerKey with the returned secret instead of listing all
keys and matching by name.
@nickvigilante
docs: regenerate provisioner keys create CLI reference
985283f
The CLI docs template now emits a Property/Value header for flag tables, so the new --output flag table needs regenerating to match make gen and pass lint/docs-html.
@nickvigilante
nickvigilante force-pushed the vigilante/cli-36-coder-provisioner-keys-create-add-o-output-with-json branch from 8a8bc83 to 985283f Compare November 11, 2026 00:10
@nickvigilante
nickvigilante temporarily deployed to main November 11, 2026 00:10 — with GitHub Actions Inactive
@nickvigilante

nickvigilante commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@untra Poking you again now that the light is green.
Today's push only rebases on main and regenerates the CLI reference for the new Property | Value flag-table header, which fixes gen, lint, and offlinedocs.
It has no code changes.

The only red check is the advisory AI doc-check, which isn't required.
It timed out waiting on its review chat, the same way it's timing out on other PRs right now.
Earlier doc-check runs on this PR passed.

This comment was generated by Coder Agents on behalf of @nickvigilante.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

untra
untra approved these changes Nov 11, 2026
View reviewed changes
@nickvigilante
nickvigilante merged commit 3def3bf into main Nov 12, 2026
32 of 34 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nickvigilante
nickvigilante deleted the vigilante/cli-36-coder-provisioner-keys-create-add-o-output-with-json branch November 12, 2026 13:58
@nickvigilante
nickvigilante temporarily deployed to main November 12, 2026 13:58 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026

This branch was previously deployed

1 inactive deployment
main — 985283f4 Deployed Nov 12, 2026 by nickvigilante via cla #254952
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@untra untra untra approved these changes
@matifali matifali Awaiting requested review from matifali
@jeremyruppel jeremyruppel Awaiting requested review from jeremyruppel

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@nickvigilante nickvigilante

Labels

cli Area: CLI

Projects

None yet

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.

4 participants

@nickvigilante @matifali @jeremyruppel @untra
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.