-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See coder/coder#9287 I decided to drop the `agent` portion from the name. It seemed inconsistent with `coder_app`.
- Loading branch information
Showing
11 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,5 +40,3 @@ resource "coder_agent_instance" "dev" { | |
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,5 +80,3 @@ Optional: | |
Read-Only: | ||
|
||
- `is_null` (Boolean) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "coder_script Resource - terraform-provider-coder" | ||
subcategory: "" | ||
description: |- | ||
Use this resource to run a script from an agent. | ||
--- | ||
|
||
# coder_script (Resource) | ||
|
||
Use this resource to run a script from an agent. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `agent_id` (String) The "id" property of a "coder_agent" resource to associate with. | ||
- `script` (String) The script to run. | ||
|
||
### Optional | ||
|
||
- `login_before_ready` (Boolean) This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the script is done and has exited. When enabled, users may see an incomplete workspace when logging in. | ||
- `run_on_start` (Boolean) This option defines whether or not the script should run when the agent starts. | ||
- `run_on_stop` (Boolean) This option defines whether or not the script should run when the agent stops. | ||
- `schedule` (String) The schedule to run the script on. This is a cron expression. | ||
- `timeout` (Number) Time in seconds until the agent lifecycle status is marked as timed out, this happens when the script has not completed (exited) in the given time. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
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 scriptResource() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Use this resource to run a script from an agent.", | ||
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, | ||
}, | ||
"display_name": { | ||
Type: schema.TypeString, | ||
Description: "The display name of the script to display logs in the dashboard.", | ||
ForceNew: true, | ||
Required: true, | ||
}, | ||
"log_path": { | ||
Type: schema.TypeString, | ||
Description: "The path of a file to write the logs to. If relative, it will be appended to tmp.", | ||
ForceNew: true, | ||
Optional: true, | ||
}, | ||
"icon": { | ||
Type: schema.TypeString, | ||
ForceNew: true, | ||
Optional: true, | ||
Description: "A URL to an icon that will display in the dashboard. View built-in " + | ||
"icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a " + | ||
"built-in icon with `data.coder_workspace.me.access_url + \"/icon/<path>\"`.", | ||
}, | ||
"source": { | ||
ForceNew: true, | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The script to run.", | ||
}, | ||
"cron": { | ||
ForceNew: true, | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The cron schedule to run the script on. This is a cron expression.", | ||
}, | ||
"start_blocks_login": { | ||
Type: schema.TypeBool, | ||
Default: false, | ||
ForceNew: true, | ||
Optional: true, | ||
Description: "This option defines whether or not the user can (by default) login to the workspace before this script completes running on start. When enabled, users may see an incomplete workspace when logging in.", | ||
}, | ||
"run_on_start": { | ||
Type: schema.TypeBool, | ||
Default: false, | ||
ForceNew: true, | ||
Optional: true, | ||
Description: "This option defines whether or not the script should run when the agent starts.", | ||
}, | ||
"run_on_stop": { | ||
Type: schema.TypeBool, | ||
Default: false, | ||
ForceNew: true, | ||
Optional: true, | ||
Description: "This option defines whether or not the script should run when the agent stops.", | ||
}, | ||
"timeout": { | ||
Type: schema.TypeInt, | ||
Default: 0, | ||
ForceNew: true, | ||
Optional: true, | ||
Description: "Time in seconds until the agent lifecycle status is marked as timed out, this happens when the script has not completed (exited) in the given time.", | ||
ValidateFunc: validation.IntAtLeast(1), | ||
}, | ||
}, | ||
} | ||
} |