diff --git a/docs/data-sources/workspace.md b/docs/data-sources/workspace.md index 84422697..b570d939 100644 --- a/docs/data-sources/workspace.md +++ b/docs/data-sources/workspace.md @@ -30,6 +30,7 @@ resource "kubernetes_pod" "dev" { - `id` (String) UUID of the workspace. - `name` (String) Name of the workspace. - `owner` (String) Username of the workspace owner. +- `owner_email` (String) Email address of the workspace owner. - `owner_id` (String) UUID of the workspace owner. - `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/internal/provider/provider.go b/internal/provider/provider.go index 6cd986b0..ac8b67f0 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -69,31 +69,40 @@ func New() *schema.Provider { count = 1 } _ = rd.Set("start_count", count) + owner := os.Getenv("CODER_WORKSPACE_OWNER") if owner == "" { owner = "default" } _ = rd.Set("owner", owner) + + ownerEmail := os.Getenv("CODER_WORKSPACE_OWNER_EMAIL") + _ = rd.Set("owner_email", ownerEmail) + ownerID := os.Getenv("CODER_WORKSPACE_OWNER_ID") if ownerID == "" { ownerID = uuid.Nil.String() } _ = rd.Set("owner_id", ownerID) + name := os.Getenv("CODER_WORKSPACE_NAME") if name == "" { name = "default" } rd.Set("name", name) + id := os.Getenv("CODER_WORKSPACE_ID") if id == "" { id = uuid.NewString() } rd.SetId(id) + config, valid := i.(config) if !valid { return diag.Errorf("config was unexpected type %q", reflect.TypeOf(i).String()) } rd.Set("access_url", config.URL.String()) + return nil }, Schema: map[string]*schema.Schema{ @@ -117,6 +126,11 @@ func New() *schema.Provider { Computed: true, Description: "Username of the workspace owner.", }, + "owner_email": { + Type: schema.TypeString, + Computed: true, + Description: "Email address of the workspace owner.", + }, "owner_id": { Type: schema.TypeString, Computed: true, diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 6a345d23..0f2d45e0 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -19,7 +19,9 @@ func TestProvider(t *testing.T) { } func TestWorkspace(t *testing.T) { - t.Parallel() + t.Setenv("CODER_WORKSPACE_OWNER", "owner123") + t.Setenv("CODER_WORKSPACE_OWNER_EMAIL", "owner123@example.com") + resource.Test(t, resource.TestCase{ Providers: map[string]*schema.Provider{ "coder": provider.New(), @@ -37,9 +39,13 @@ func TestWorkspace(t *testing.T) { require.Len(t, state.Modules[0].Resources, 1) resource := state.Modules[0].Resources["data.coder_workspace.me"] require.NotNil(t, resource) - value := resource.Primary.Attributes["transition"] + + attribs := resource.Primary.Attributes + value := attribs["transition"] require.NotNil(t, value) t.Log(value) + require.Equal(t, "owner123", attribs["owner"]) + require.Equal(t, "owner123@example.com", attribs["owner_email"]) return nil }, }}, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy