Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit27ea32d

Browse files
kylecarbsDanielleMaywood
authored andcommitted
feat: Expose owner and workspace IDs to "coder_workspace" (#12)
This allows for simpler persistence of resources thatshouldn't be deleted when a user changes their name.
1 parent2291fc0 commit27ea32d

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

‎docs/data-sources/workspace.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ resource "kubernetes_pod" "dev" {
2424
<!-- schema generated by tfplugindocs-->
2525
##Schema
2626

27-
###Optional
28-
29-
-`id` (String) The ID of this resource.
30-
3127
###Read-Only
3228

29+
-`id` (String) UUID of the workspace.
3330
-`name` (String) Name of the workspace.
3431
-`owner` (String) Username of the workspace owner.
32+
-`owner_id` (String) UUID of the workspace owner.
3533
-`start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
3634
-`transition` (String) Either "start" or "stop". Use this to start/stop resources with "count".
3735

‎internal/provider/provider.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func New() *schema.Provider {
5858
"coder_workspace": {
5959
Description:"Use this data source to get information for the active workspace build.",
6060
ReadContext:func(c context.Context,rd*schema.ResourceData,iinterface{}) diag.Diagnostics {
61-
rd.SetId(uuid.NewString())
6261
transition:=os.Getenv("CODER_WORKSPACE_TRANSITION")
6362
iftransition=="" {
6463
// Default to start!
@@ -75,11 +74,21 @@ func New() *schema.Provider {
7574
owner="default"
7675
}
7776
_=rd.Set("owner",owner)
77+
ownerID:=os.Getenv("CODER_WORKSPACE_OWNER_ID")
78+
ifownerID=="" {
79+
ownerID=uuid.Nil.String()
80+
}
81+
_=rd.Set("owner_id",ownerID)
7882
name:=os.Getenv("CODER_WORKSPACE_NAME")
7983
ifname=="" {
8084
name="default"
8185
}
8286
rd.Set("name",name)
87+
id:=os.Getenv("CODER_WORKSPACE_ID")
88+
ifid=="" {
89+
id=uuid.NewString()
90+
}
91+
rd.SetId(id)
8392
returnnil
8493
},
8594
Schema:map[string]*schema.Schema{
@@ -98,6 +107,16 @@ func New() *schema.Provider {
98107
Computed:true,
99108
Description:"Username of the workspace owner.",
100109
},
110+
"owner_id": {
111+
Type:schema.TypeString,
112+
Computed:true,
113+
Description:"UUID of the workspace owner.",
114+
},
115+
"id": {
116+
Type:schema.TypeString,
117+
Computed:true,
118+
Description:"UUID of the workspace.",
119+
},
101120
"name": {
102121
Type:schema.TypeString,
103122
Computed:true,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp