Files
coder/docs/reference/cli/provisioner/keys/create.md
T
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

45 lines
1.0 KiB
Markdown
Generated

---
# Code generated by make gen. DO NOT EDIT.
title: "`coder provisioner keys create`"
description: Create a new provisioner key.
---
<!-- DO NOT EDIT | GENERATED CONTENT -->
Create a new provisioner key
## Usage
```console
coder provisioner keys create [flags] <name>
```
## Options
### -t, --tag
| Property | Value |
|-------------|---------------------------------------|
| Type | <code>string-array</code> |
| Environment | <code>$CODER_PROVISIONERD_TAGS</code> |
Tags to filter provisioner jobs by.
### -O, --org
| Property | Value |
|-------------|----------------------------------|
| Type | <code>string</code> |
| Environment | <code>$CODER_ORGANIZATION</code> |
Select which organization (uuid or name) to use.
### -o, --output
| Property | Value |
|----------|-------------------------|
| Type | <code>text\|json</code> |
| Default | <code>text</code> |
Output format.