Skip to content

Commit

Permalink
feat: add owner_oidc_access_token to coder_workspace data source (#…
Browse files Browse the repository at this point in the history
…91)

This was requested by multiple community members in Discord:
https://discord.com/channels/747933592273027093/1071182088490987542/1071182088490987542
  • Loading branch information
kylecarbs authored Mar 17, 2023
1 parent 6fe7fc2 commit dd15752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/data-sources/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resource "kubernetes_pod" "dev" {
- `owner` (String) Username of the workspace owner.
- `owner_email` (String) Email address of the workspace owner.
- `owner_id` (String) UUID of the workspace owner.
- `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.
- `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
- `transition` (String) Either "start" or "stop". Use this to start/stop resources with "count".

Expand Down
10 changes: 10 additions & 0 deletions provider/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func workspaceDataSource() *schema.Resource {
}
_ = rd.Set("owner_id", ownerID)

ownerOIDCAccessToken := os.Getenv("CODER_WORKSPACE_OWNER_OIDC_ACCESS_TOKEN")
_ = rd.Set("owner_oidc_access_token", ownerOIDCAccessToken)

name := os.Getenv("CODER_WORKSPACE_NAME")
if name == "" {
name = "default"
Expand Down Expand Up @@ -111,6 +114,13 @@ func workspaceDataSource() *schema.Resource {
Computed: true,
Description: "UUID of the workspace owner.",
},
"owner_oidc_access_token": {
Type: schema.TypeString,
Computed: true,
Description: "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.",
},
"id": {
Type: schema.TypeString,
Computed: true,
Expand Down

0 comments on commit dd15752

Please sign in to comment.