Files
Nick VigilanteandJeremy Ruppel 3def3bf5a3 feat: add JSON output to coder provisioner keys create (#30152)
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.

<details>
<summary>Decisions</summary>

- `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.

</details>

Closes [CLI-36](https://linear.app/codercom/issue/CLI-36)

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

---------

Co-authored-by: Jeremy Ruppel <jeremyruppel@users.noreply.github.com>
2026-11-12 08:58:37 -05:00

1.0 KiB
Generated

title, description
title description
`coder provisioner keys create` Create a new provisioner key.

Create a new provisioner key

Usage

coder provisioner keys create [flags] <name>

Options

-t, --tag

Property Value
Type string-array
Environment $CODER_PROVISIONERD_TAGS

Tags to filter provisioner jobs by.

-O, --org

Property Value
Type string
Environment $CODER_ORGANIZATION

Select which organization (uuid or name) to use.

-o, --output

Property Value
Type text|json
Default text

Output format.