mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add coder secret import for bulk secret files (#27534)
Adds `coder secret import <file>` to bulk-import dotenv, JSON, or YAML secrets through the existing batch API. The command infers the format from the extension or accepts `--input-format`, supports non-interactive stdin, validates files locally before upload, and warns when imported keys cannot be injected as environment variables. Reviewed and updated by Coder Agents on behalf of @dylanhuff-at-coder.
This commit is contained in:
@@ -217,6 +217,23 @@ want to store a trailing newline:
|
||||
echo -n "$API_KEY" | coder secret create api-key --env API_KEY
|
||||
```
|
||||
|
||||
### Import multiple secrets from a file
|
||||
|
||||
Use `coder secret import <file>` to create a secret for every key in a dotenv,
|
||||
JSON, or YAML file. The format is inferred from the file extension. Pass `-`
|
||||
to read from non-interactive stdin, which requires `--input-format`:
|
||||
|
||||
```sh
|
||||
coder secret import ./secrets.env
|
||||
|
||||
coder secret import - --input-format yaml < ./secrets.yaml
|
||||
```
|
||||
|
||||
The import is all or nothing and never overwrites existing secrets. Keys that
|
||||
are valid environment variable names are injected under the same name; other
|
||||
keys are imported without an environment variable target. For details, see
|
||||
[`coder secret import`](../reference/cli/secret_import.md).
|
||||
|
||||
### Create a disabled secret
|
||||
|
||||
An enabled secret must set `--env`, `--file`, or both. To store a secret
|
||||
|
||||
Reference in New Issue
Block a user