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

Commit058bb74

Browse files
committed
WIP: resourcepools resources
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent493a0f1 commit058bb74

File tree

2 files changed

+105
-6
lines changed

2 files changed

+105
-6
lines changed

‎provider/pool_resource_claim.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package provider
2+
3+
import (
4+
"context"
5+
6+
"github.com/google/uuid"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9+
)
10+
11+
funcpoolResourceClaimResource()*schema.Resource {
12+
return&schema.Resource{
13+
SchemaVersion:1,
14+
15+
Description:"Use this resource to claim a resource pool entry.",
16+
CreateContext:func(_ context.Context,resourceData*schema.ResourceData,iinterface{}) diag.Diagnostics {
17+
resourceData.SetId(uuid.NewString())
18+
returnnil
19+
},
20+
ReadContext:func(ctx context.Context,resourceData*schema.ResourceData,iinterface{}) diag.Diagnostics {
21+
// poolb64 := base64.StdEncoding.EncodeToString([]byte(resourceData.Get("pool_name").(string)))
22+
// key := fmt.Sprintf("CODER_RESOURCE_POOL_%s_ENTRY_OBJECT_ID", poolb64)
23+
// objectId, err := helpers.RequireEnv(key)
24+
// if err != nil {
25+
// return diag.Errorf("resource pool entry object ID not found in env %q: %s", key, err)
26+
// }
27+
//
28+
// if err = resourceData.Set("object_id", objectId); err != nil {
29+
// return diag.Errorf("failed to set resource pool entry object ID: %s", err)
30+
// }
31+
returnnil
32+
},
33+
DeleteContext:func(ctx context.Context,resourceData*schema.ResourceData,iinterface{}) diag.Diagnostics {
34+
returnnil
35+
},
36+
Schema:map[string]*schema.Schema{
37+
"pool_name": {
38+
Type:schema.TypeString,
39+
Required:true,
40+
ForceNew:true,
41+
Description:"The name of the pool from which an entry will be claimed.",
42+
},
43+
"object_id": {
44+
Type:schema.TypeString,
45+
Computed:true,
46+
Description:"The object ID of the pooled entry resource",
47+
},
48+
},
49+
}
50+
}
51+
52+
funcpoolResourceClaimableResource()*schema.Resource {
53+
return&schema.Resource{
54+
SchemaVersion:1,
55+
56+
Description:"Use this resource to specify which resources are claimable by workspaces.",
57+
CreateContext:func(_ context.Context,resourceData*schema.ResourceData,iinterface{}) diag.Diagnostics {
58+
resourceData.SetId(uuid.NewString())
59+
returnnil
60+
},
61+
ReadContext:func(ctx context.Context,resourceData*schema.ResourceData,iinterface{}) diag.Diagnostics {
62+
returnnil
63+
},
64+
DeleteContext:func(ctx context.Context,resourceData*schema.ResourceData,iinterface{}) diag.Diagnostics {
65+
returnnil
66+
},
67+
Schema:map[string]*schema.Schema{
68+
"compute": {
69+
Type:schema.TypeSet,
70+
ForceNew:true,
71+
Optional:true,
72+
ConflictsWith: []string{"other"},
73+
Elem:&schema.Resource{
74+
Schema:map[string]*schema.Schema{
75+
"instance_id": {
76+
Type:schema.TypeString,
77+
Description:"The ID of the compute instance (container/VM/etc).",
78+
ForceNew:true,
79+
Required:true,
80+
},
81+
"agent_id": {
82+
Type:schema.TypeString,
83+
Description:"The ID of the agent running inside the compute instance.",
84+
ForceNew:true,
85+
Required:true,
86+
},
87+
},
88+
},
89+
},
90+
"other": {
91+
Type:schema.TypeString,
92+
ForceNew:true,
93+
Optional:true,
94+
},
95+
},
96+
}
97+
}

‎provider/provider.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ func New() *schema.Provider {
6969
"coder_workspace_owner":workspaceOwnerDataSource(),
7070
},
7171
ResourcesMap:map[string]*schema.Resource{
72-
"coder_agent":agentResource(),
73-
"coder_agent_instance":agentInstanceResource(),
74-
"coder_app":appResource(),
75-
"coder_metadata":metadataResource(),
76-
"coder_script":scriptResource(),
77-
"coder_env":envResource(),
72+
"coder_agent":agentResource(),
73+
"coder_agent_instance":agentInstanceResource(),
74+
"coder_app":appResource(),
75+
"coder_metadata":metadataResource(),
76+
"coder_script":scriptResource(),
77+
"coder_env":envResource(),
78+
"coder_pool_resource_claim":poolResourceClaimResource(),
79+
"coder_pool_resource_claimable":poolResourceClaimableResource(),
7880
},
7981
}
8082
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp