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

feat: Expose owner and workspace IDs to "coder_workspace"#12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 1 commit intomainfromids
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
6 changes: 2 additions & 4 deletionsdocs/data-sources/workspace.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,14 +24,12 @@ resource "kubernetes_pod" "dev" {
<!-- schema generated by tfplugindocs-->
##Schema

###Optional

-`id` (String) The ID of this resource.

###Read-Only

-`id` (String) UUID of the workspace.
-`name` (String) Name of the workspace.
-`owner` (String) Username 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".

Expand Down
21 changes: 20 additions & 1 deletioninternal/provider/provider.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,6 @@ func New() *schema.Provider {
"coder_workspace": {
Description:"Use this data source to get information for the active workspace build.",
ReadContext:func(c context.Context,rd*schema.ResourceData,iinterface{}) diag.Diagnostics {
rd.SetId(uuid.NewString())
transition:=os.Getenv("CODER_WORKSPACE_TRANSITION")
iftransition=="" {
// Default to start!
Expand All@@ -75,11 +74,21 @@ func New() *schema.Provider {
owner="default"
}
_=rd.Set("owner",owner)
ownerID:=os.Getenv("CODER_WORKSPACE_OWNER_ID")
ifownerID=="" {
ownerID=uuid.Nil.String()
}
_=rd.Set("owner_id",ownerID)
name:=os.Getenv("CODER_WORKSPACE_NAME")
ifname=="" {
name="default"
}
rd.Set("name",name)
id:=os.Getenv("CODER_WORKSPACE_ID")
ifid=="" {
id=uuid.NewString()
}
rd.SetId(id)
returnnil
},
Schema:map[string]*schema.Schema{
Expand All@@ -98,6 +107,16 @@ func New() *schema.Provider {
Computed:true,
Description:"Username of the workspace owner.",
},
"owner_id": {
Type:schema.TypeString,
Computed:true,
Description:"UUID of the workspace owner.",
},
"id": {
Type:schema.TypeString,
Computed:true,
Description:"UUID of the workspace.",
},
"name": {
Type:schema.TypeString,
Computed:true,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp