Skip to content

Commit 8785d49

Browse files
authored
feat: add to workspace (#181)
1 parent 8eb25b4 commit 8785d49

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

Diff for: docs/data-sources/workspace.md

+1
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_name` (String) Name of the workspace owner.
3637
- `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.
3738
- `owner_session_token` (String) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.
3839
- `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.

Diff for: provider/workspace.go

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func workspaceDataSource() *schema.Resource {
3636
ownerEmail := os.Getenv("CODER_WORKSPACE_OWNER_EMAIL")
3737
_ = rd.Set("owner_email", ownerEmail)
3838

39+
ownerName := os.Getenv("CODER_WORKSPACE_OWNER_NAME")
40+
_ = rd.Set("owner_name", ownerName)
41+
3942
ownerID := os.Getenv("CODER_WORKSPACE_OWNER_ID")
4043
if ownerID == "" {
4144
ownerID = uuid.Nil.String()
@@ -126,6 +129,11 @@ func workspaceDataSource() *schema.Resource {
126129
Computed: true,
127130
Description: "UUID of the workspace owner.",
128131
},
132+
"owner_name": {
133+
Type: schema.TypeString,
134+
Computed: true,
135+
Description: "Name of the workspace owner.",
136+
},
129137
"owner_oidc_access_token": {
130138
Type: schema.TypeString,
131139
Computed: true,

Diff for: provider/workspace_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
func TestWorkspace(t *testing.T) {
1515
t.Setenv("CODER_WORKSPACE_OWNER", "owner123")
16+
t.Setenv("CODER_WORKSPACE_OWNER_NAME", "Mr Owner")
1617
t.Setenv("CODER_WORKSPACE_OWNER_EMAIL", "[email protected]")
1718
t.Setenv("CODER_WORKSPACE_OWNER_SESSION_TOKEN", "abc123")
1819
t.Setenv("CODER_WORKSPACE_TEMPLATE_ID", "templateID")
@@ -43,6 +44,7 @@ func TestWorkspace(t *testing.T) {
4344
t.Log(value)
4445
require.Equal(t, "8080", attribs["access_port"])
4546
require.Equal(t, "owner123", attribs["owner"])
47+
require.Equal(t, "Mr Owner", attribs["owner_name"])
4648
require.Equal(t, "[email protected]", attribs["owner_email"])
4749
require.Equal(t, "abc123", attribs["owner_session_token"])
4850
require.Equal(t, "templateID", attribs["template_id"])
@@ -76,6 +78,7 @@ func TestWorkspace(t *testing.T) {
7678
t.Log(value)
7779
require.Equal(t, "https://example.com:8080", attribs["access_url"])
7880
require.Equal(t, "owner123", attribs["owner"])
81+
require.Equal(t, "Mr Owner", attribs["owner_name"])
7982
require.Equal(t, "[email protected]", attribs["owner_email"])
8083
require.Equal(t, "templateID", attribs["template_id"])
8184
require.Equal(t, "template123", attribs["template_name"])

0 commit comments

Comments
 (0)