Skip to content

Commit 39c246e

Browse files
committed
feat: add coder_file resource
1 parent a5ea153 commit 39c246e

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

docs/resources/file.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "coder_file Resource - terraform-provider-coder"
4+
subcategory: ""
5+
description: |-
6+
Use this resource to place a file inside of a workspace.
7+
---
8+
9+
# coder_file (Resource)
10+
11+
Use this resource to place a file inside of a workspace.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `agent_id` (String) The "id" property of a "coder_agent" resource to associate with.
21+
- `content` (String) The content of the file to place in the workspace.
22+
- `path` (String) The path of the file to place in the workspace.
23+
24+
### Optional
25+
26+
- `mode` (Number) The mode of the file to place in the workspace.
27+
28+
### Read-Only
29+
30+
- `id` (String) The ID of this resource.

provider/file.go

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
10+
)
11+
12+
func fileResource() *schema.Resource {
13+
return &schema.Resource{
14+
Description: "Use this resource to place a file inside of a workspace.",
15+
CreateContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics {
16+
rd.SetId(uuid.NewString())
17+
return nil
18+
},
19+
ReadContext: schema.NoopContext,
20+
DeleteContext: schema.NoopContext,
21+
Schema: map[string]*schema.Schema{
22+
"agent_id": {
23+
Type: schema.TypeString,
24+
Description: `The "id" property of a "coder_agent" resource to associate with.`,
25+
ForceNew: true,
26+
Required: true,
27+
},
28+
"path": {
29+
Type: schema.TypeString,
30+
Description: "The path of the file to place in the workspace.",
31+
ForceNew: true,
32+
Required: true,
33+
},
34+
"content": {
35+
Type: schema.TypeString,
36+
Description: "The content of the file to place in the workspace.",
37+
ForceNew: true,
38+
Required: true,
39+
},
40+
"mode": {
41+
Type: schema.TypeInt,
42+
Description: "The mode of the file to place in the workspace.",
43+
ForceNew: true,
44+
Optional: true,
45+
ValidateFunc: validation.IntBetween(0, 0777),
46+
},
47+
},
48+
}
49+
}

provider/provider.go

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func New() *schema.Provider {
7878
"coder_agent": agentResource(),
7979
"coder_agent_instance": agentInstanceResource(),
8080
"coder_app": appResource(),
81+
"coder_file": fileResource(),
8182
"coder_metadata": metadataResource(),
8283
"coder_script": scriptResource(),
8384
},

0 commit comments

Comments
 (0)