Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/data-sources/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ resource "kubernetes_pod" "dev" {
- `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.
- `owner_session_token` (String) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.
- `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
- `template_id` (String) ID of the workspace's template.
- `template_name` (String) Name of the workspace's template.
- `transition` (String) Either "start" or "stop". Use this to start/stop resources with "count".
16 changes: 16 additions & 0 deletions provider/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func workspaceDataSource() *schema.Resource {
}
rd.SetId(id)

templateID := os.Getenv("CODER_WORKSPACE_TEMPLATE_ID")
_ = rd.Set("template_id", templateID)

templateName := os.Getenv("CODER_WORKSPACE_TEMPLATE_NAME")
_ = rd.Set("template_name", templateName)

config, valid := i.(config)
if !valid {
return diag.Errorf("config was unexpected type %q", reflect.TypeOf(i).String())
Expand Down Expand Up @@ -139,6 +145,16 @@ func workspaceDataSource() *schema.Resource {
Computed: true,
Description: "Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.",
},
"template_id": {
Type: schema.TypeString,
Computed: true,
Description: "ID of the workspace's template.",
},
"template_name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the workspace's template.",
},
},
}
}
6 changes: 6 additions & 0 deletions provider/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func TestWorkspace(t *testing.T) {
t.Setenv("CODER_WORKSPACE_OWNER", "owner123")
t.Setenv("CODER_WORKSPACE_OWNER_EMAIL", "owner123@example.com")
t.Setenv("CODER_WORKSPACE_OWNER_SESSION_TOKEN", "abc123")
t.Setenv("CODER_WORKSPACE_TEMPLATE_ID", "templateID")
t.Setenv("CODER_WORKSPACE_TEMPLATE_NAME", "template123")

resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
Expand Down Expand Up @@ -42,6 +44,8 @@ func TestWorkspace(t *testing.T) {
require.Equal(t, "owner123", attribs["owner"])
require.Equal(t, "owner123@example.com", attribs["owner_email"])
require.Equal(t, "abc123", attribs["owner_session_token"])
require.Equal(t, "templateID", attribs["template_id"])
require.Equal(t, "template123", attribs["template_name"])
return nil
},
}},
Expand Down Expand Up @@ -71,6 +75,8 @@ func TestWorkspace(t *testing.T) {
require.Equal(t, "https://example.com:8080", attribs["access_url"])
require.Equal(t, "owner123", attribs["owner"])
require.Equal(t, "owner123@example.com", attribs["owner_email"])
require.Equal(t, "templateID", attribs["template_id"])
require.Equal(t, "template123", attribs["template_name"])
return nil
},
}},
Expand Down
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