feat: add coder_secret data source for user secrets#501
Merged
Conversation
cf0b74b to
ca847f0
Compare
zedkipp
commented
Apr 20, 2026
zedkipp
commented
Apr 20, 2026
ca847f0 to
100f37e
Compare
zedkipp
commented
Apr 21, 2026
| return diag.Diagnostics{{ | ||
| Severity: diag.Error, | ||
| Summary: fmt.Sprintf("Missing required secret: %s", requirement), | ||
| Detail: detail.String(), |
Contributor
Author
zedkipp
commented
Apr 21, 2026
johnstcn
approved these changes
Apr 22, 2026
Member
johnstcn
left a comment
There was a problem hiding this comment.
Looks good to me! Just one note regarding the control flow in the data source.
100f37e to
70ee398
Compare
Add a new `coder_secret` data source that allows template authors to
declare required user secrets and access their values during workspace
builds.
Schema:
- `env` (optional) — environment variable name the secret injects
- `file` (optional) — file path the secret injects
- `help_message` (required) — guidance shown when the secret is missing
- `value` (computed, sensitive) — resolved from provisioner env vars
Exactly one of `env` or `file` must be set. On start transitions, a
missing secret fails the build with the help_message. On stop/delete,
missing secrets return empty to allow teardown.
Env var convention:
- Env secrets: CODER_SECRET_ENV_{env_name}
- File secrets: CODER_SECRET_FILE_{hex(file_path)}
70ee398 to
93f2334
Compare
dylanhuff-at-coder
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Add a new
coder_secretdata source that allows template authors to declare required user secrets and access their values during workspace builds.Schema:
env(optional) — environment variable name the secret injectsfile(optional) — file path the secret injectshelp_message(required) — guidance shown when the secret is missingvalue(computed, sensitive) — resolved from provisioner env varsExactly one of
envorfilemust be set. On start transitions, a missing secret fails the build with the help_message. On stop/delete, missing secrets return empty to allow teardown.Env var convention:
RFC: https://www.notion.so/coderhq/User-Secrets-32cd579be59280a98192dec7b3b5daf1
Related coder PR: coder/coder#24542