Skip to content

Commit dd15752

Browse files
authored
feat: add owner_oidc_access_token to coder_workspace data source (#91)
This was requested by multiple community members in Discord: https://discord.com/channels/747933592273027093/1071182088490987542/1071182088490987542
1 parent 6fe7fc2 commit dd15752

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

docs/data-sources/workspace.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ resource "kubernetes_pod" "dev" {
3333
- `owner` (String) Username of the workspace owner.
3434
- `owner_email` (String) Email address of the workspace owner.
3535
- `owner_id` (String) UUID of the workspace owner.
36+
- `owner_oidc_access_token` (String) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
3637
- `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
3738
- `transition` (String) Either "start" or "stop". Use this to start/stop resources with "count".
3839

provider/workspace.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ func workspaceDataSource() *schema.Resource {
4242
}
4343
_ = rd.Set("owner_id", ownerID)
4444

45+
ownerOIDCAccessToken := os.Getenv("CODER_WORKSPACE_OWNER_OIDC_ACCESS_TOKEN")
46+
_ = rd.Set("owner_oidc_access_token", ownerOIDCAccessToken)
47+
4548
name := os.Getenv("CODER_WORKSPACE_NAME")
4649
if name == "" {
4750
name = "default"
@@ -111,6 +114,13 @@ func workspaceDataSource() *schema.Resource {
111114
Computed: true,
112115
Description: "UUID of the workspace owner.",
113116
},
117+
"owner_oidc_access_token": {
118+
Type: schema.TypeString,
119+
Computed: true,
120+
Description: "A valid OpenID Connect access token of the workspace owner. " +
121+
"This is only available if the workspace owner authenticated with OpenID Connect. " +
122+
"If a valid token cannot be obtained, this value will be an empty string.",
123+
},
114124
"id": {
115125
Type: schema.TypeString,
116126
Computed: true,

0 commit comments

Comments
 (0)