Skip to content

feat: add coder_file resource #164

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
30 changes: 30 additions & 0 deletions docs/resources/file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "coder_file Resource - terraform-provider-coder"
subcategory: ""
description: |-
Use this resource to place a file inside of a workspace.
---

# coder_file (Resource)

Use this resource to place a file inside of a workspace.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `agent_id` (String) The "id" property of a "coder_agent" resource to associate with.
- `content` (String) The content of the file to place in the workspace.
- `path` (String) The path of the file to place in the workspace.

### Optional

- `mode` (Number) The mode of the file to place in the workspace.

### Read-Only

- `id` (String) The ID of this resource.
49 changes: 49 additions & 0 deletions provider/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package provider

import (
"context"

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func fileResource() *schema.Resource {
return &schema.Resource{
Description: "Use this resource to place a file inside of a workspace.",
CreateContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics {
rd.SetId(uuid.NewString())
return nil
},
ReadContext: schema.NoopContext,
DeleteContext: schema.NoopContext,
Schema: map[string]*schema.Schema{
"agent_id": {
Type: schema.TypeString,
Description: `The "id" property of a "coder_agent" resource to associate with.`,
ForceNew: true,
Required: true,
},
"path": {
Type: schema.TypeString,
Description: "The path of the file to place in the workspace.",
ForceNew: true,
Required: true,
},
"content": {
Type: schema.TypeString,
Description: "The content of the file to place in the workspace.",
ForceNew: true,
Required: true,
},
"mode": {
Type: schema.TypeInt,
Description: "The mode of the file to place in the workspace.",
ForceNew: true,
Optional: true,
ValidateFunc: validation.IntBetween(0, 0777),
},
},
}
}
1 change: 1 addition & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func New() *schema.Provider {
"coder_agent": agentResource(),
"coder_agent_instance": agentInstanceResource(),
"coder_app": appResource(),
"coder_file": fileResource(),
"coder_metadata": metadataResource(),
"coder_script": scriptResource(),
},
Expand Down
Loading