From d5a8cdd5ac3a7326d3c63ac2e0415e6e8019a295 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Sun, 5 Feb 2023 21:14:35 +0000 Subject: [PATCH] feat: add `owner_oidc_access_token` to `coder_workspace` data source This was requested by multiple community members in Discord: https://discord.com/channels/747933592273027093/1071182088490987542/1071182088490987542 --- docs/data-sources/parameter.md | 1 + docs/data-sources/workspace.md | 1 + provider/workspace.go | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/docs/data-sources/parameter.md b/docs/data-sources/parameter.md index 20b61ddd..70750742 100644 --- a/docs/data-sources/parameter.md +++ b/docs/data-sources/parameter.md @@ -56,6 +56,7 @@ Optional: - `error` (String) An error message to display if the value doesn't match the provided regex. - `max` (Number) The maximum of a number parameter. - `min` (Number) The minimum of a number parameter. +- `monotonic` (String) Number monotonicity, either increasing or decreasing. - `regex` (String) A regex for the input parameter to match against. diff --git a/docs/data-sources/workspace.md b/docs/data-sources/workspace.md index 665fef2b..865a2d98 100644 --- a/docs/data-sources/workspace.md +++ b/docs/data-sources/workspace.md @@ -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". diff --git a/provider/workspace.go b/provider/workspace.go index 6b2175e5..797acc60 100644 --- a/provider/workspace.go +++ b/provider/workspace.go @@ -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" @@ -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,