- Notifications
You must be signed in to change notification settings - Fork22
feat: Add app support#17
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "coder_app Resource - terraform-provider-coder" | ||
subcategory: "" | ||
description: |- | ||
Use this resource to define shortcuts to access applications in a workspace. | ||
--- | ||
# coder_app (Resource) | ||
Use this resource to define shortcuts to access applications in a workspace. | ||
## Example Usage | ||
```terraform | ||
data "coder_workspace" "me" {} | ||
resource "coder_agent" "dev" { | ||
os = "linux" | ||
arch = "amd64" | ||
dir = "/workspace" | ||
startup_script = <<EOF | ||
curl -fsSL https://code-server.dev/install.sh | sh | ||
code-server --auth none --port 13337 | ||
EOF | ||
} | ||
resource "coder_app" "code-server" { | ||
agent_id = coder_agent.dev.id | ||
name = "VS Code" | ||
icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" | ||
target = "http://localhost:13337" | ||
} | ||
resource "coder_app" "vim" { | ||
agent_id = coder_agent.dev.id | ||
name = "Vim" | ||
icon = data.coder_workspace.me.access_url + "/icons/vim.svg" | ||
command = "vim" | ||
} | ||
resource "coder_app" "intellij" { | ||
agent_id = coder_agent.dev.id | ||
icon = data.coder_workspace.me.access_url + "/icons/intellij.svg" | ||
name = "JetBrains IntelliJ" | ||
command = "projector run" | ||
} | ||
``` | ||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
### Required | ||
- `agent_id` (String) The "id" property of a "coder_agent" resource to associate with. | ||
### Optional | ||
- `command` (String) A command to run in a terminal opening this app. In the web, this will open in a new tab. In the CLI, this will SSH and execute the command. | ||
- `icon` (String) 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/icons. Use a built-in icon with `data.coder_workspace.me.access_url + "/icons/<path>"`. | ||
- `id` (String) The ID of this resource. | ||
- `name` (String) A display name to identify the app. | ||
- `target` (String) A URL to be proxied to from inside the workspace. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
data "coder_workspace" "me" {} | ||
resource "coder_agent" "dev" { | ||
os = "linux" | ||
arch = "amd64" | ||
dir = "/workspace" | ||
startup_script = <<EOF | ||
curl -fsSL https://code-server.dev/install.sh | sh | ||
code-server --auth none --port 13337 | ||
EOF | ||
} | ||
resource "coder_app" "code-server" { | ||
agent_id = coder_agent.dev.id | ||
name = "VS Code" | ||
icon = data.coder_workspace.me.access_url + "/icons/vscode.svg" | ||
target = "http://localhost:13337" | ||
} | ||
resource "coder_app" "vim" { | ||
agent_id = coder_agent.dev.id | ||
name = "Vim" | ||
icon = data.coder_workspace.me.access_url + "/icons/vim.svg" | ||
command = "vim" | ||
} | ||
resource "coder_app" "intellij" { | ||
agent_id = coder_agent.dev.id | ||
icon = data.coder_workspace.me.access_url + "/icons/intellij.svg" | ||
name = "JetBrains IntelliJ" | ||
command = "projector run" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -89,9 +89,19 @@ func New() *schema.Provider { | ||
id = uuid.NewString() | ||
} | ||
rd.SetId(id) | ||
config, valid := i.(config) | ||
if !valid { | ||
return diag.Errorf("config was unexpected type %q", reflect.TypeOf(i).String()) | ||
} | ||
rd.Set("access_url", config.URL.String()) | ||
return nil | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
"access_url": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The access URL of the Coder deployment provisioning this workspace.", | ||
}, | ||
"start_count": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
@@ -227,6 +237,65 @@ func New() *schema.Provider { | ||
}, | ||
}, | ||
}, | ||
"coder_app": { | ||
Description: "Use this resource to define shortcuts to access applications in a workspace.", | ||
CreateContext: func(c context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { | ||
resourceData.SetId(uuid.NewString()) | ||
return nil | ||
}, | ||
ReadContext: func(c context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { | ||
return nil | ||
}, | ||
DeleteContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics { | ||
return nil | ||
}, | ||
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, | ||
}, | ||
"command": { | ||
Type: schema.TypeString, | ||
Description: "A command to run in a terminal opening this app. In the web, " + | ||
"this will open in a new tab. In the CLI, this will SSH and execute the command. " + | ||
"Either \"command\" or \"target\" may be specified, but not both.", | ||
ConflictsWith: []string{"target"}, | ||
Optional: true, | ||
ForceNew: true, | ||
}, | ||
"icon": { | ||
Type: schema.TypeString, | ||
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/icons. Use a " + | ||
"built-in icon with `data.coder_workspace.me.access_url + \"/icons/<path>\"`.", | ||
ForceNew: true, | ||
Optional: true, | ||
ValidateFunc: func(i interface{}, s string) ([]string, []error) { | ||
_, err := url.Parse(s) | ||
if err != nil { | ||
return nil, []error{err} | ||
} | ||
return nil, nil | ||
}, | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Description: "A display name to identify the app.", | ||
ForceNew: true, | ||
Optional: true, | ||
}, | ||
"target": { | ||
Type: schema.TypeString, | ||
Description: "A URL to be proxied to from inside the workspace. " + | ||
"Either \"command\" or \"target\" may be specified, but not both.", | ||
ForceNew: true, | ||
Optional: true, | ||
ConflictsWith: []string{"command"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We don't seem to document the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. True. I shall fix! | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||