-
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.
feat: Add "coder_parameter" to expose richer parameter types (#57)
* Add parameter * add parameter package * Use mapstructure for parsing parameters * Remove unused lib * Change to mutable
- Loading branch information
Showing
6 changed files
with
731 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Terraform Provider Coder | ||
# terraform-provider-coder | ||
|
||
> This works with a closed-alpha of [Coder](https://coder.com). For access, contact [support@coder.com](mailto:support@coder.com). | ||
See [Coder](https://github.com/coder/coder). |
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,60 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "coder_parameter Data Source - terraform-provider-coder" | ||
subcategory: "" | ||
description: |- | ||
Use this data source to configure editable options for workspaces. | ||
--- | ||
|
||
# coder_parameter (Data Source) | ||
|
||
Use this data source to configure editable options for workspaces. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The name of the parameter as it will appear in the interface. If this is changed, developers will be re-prompted for a new value. | ||
|
||
### Optional | ||
|
||
- `default` (String) A default value for the parameter. | ||
- `description` (String) Describe what this parameter does. | ||
- `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/icon. Use a built-in icon with `data.coder_workspace.me.access_url + "/icon/<path>"`. | ||
- `mutable` (Boolean) Whether this value can be changed after workspace creation. This can be destructive for values like region, so use with caution! | ||
- `option` (Block List, Max: 64) Each "option" block defines a value for a user to select from. (see [below for nested schema](#nestedblock--option)) | ||
- `type` (String) The type of this parameter. Must be one of: "number", "string", or "bool". | ||
- `validation` (Block List, Max: 1) Validate the input of a parameter. (see [below for nested schema](#nestedblock--validation)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `value` (String) The output value of the parameter. | ||
|
||
<a id="nestedblock--option"></a> | ||
### Nested Schema for `option` | ||
|
||
Required: | ||
|
||
- `name` (String) The display name of this value in the UI. | ||
- `value` (String) The value of this option set on the parameter if selected. | ||
|
||
Optional: | ||
|
||
- `description` (String) Describe what selecting this value does. | ||
- `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/icon. Use a built-in icon with `data.coder_workspace.me.access_url + "/icon/<path>"`. | ||
|
||
|
||
<a id="nestedblock--validation"></a> | ||
### Nested Schema for `validation` | ||
|
||
Optional: | ||
|
||
- `max` (Number) The maximum of a number parameter. | ||
- `min` (Number) The minimum of a number parameter. | ||
- `regex` (String) A regex for the input parameter to match against. | ||
|
||
|
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,46 @@ | ||
data "coder_parameter" "example" { | ||
display_name = "Region" | ||
description = "Specify a region to place your workspace." | ||
immutable = true | ||
type = "string" | ||
option { | ||
value = "us-central1-a" | ||
label = "US Central" | ||
icon = "/icon/usa.svg" | ||
} | ||
option { | ||
value = "asia-central1-a" | ||
label = "Asia" | ||
icon = "/icon/asia.svg" | ||
} | ||
} | ||
|
||
data "coder_parameter" "ami" { | ||
display_name = "Machine Image" | ||
option { | ||
value = "ami-xxxxxxxx" | ||
label = "Ubuntu" | ||
icon = "/icon/ubuntu.svg" | ||
} | ||
} | ||
|
||
data "coder_parameter" "image" { | ||
display_name = "Docker Image" | ||
icon = "/icon/docker.svg" | ||
type = "bool" | ||
} | ||
|
||
data "coder_parameter" "cores" { | ||
display_name = "CPU Cores" | ||
icon = "/icon/" | ||
} | ||
|
||
data "coder_parameter" "disk_size" { | ||
display_name = "Disk Size" | ||
type = "number" | ||
validation { | ||
# This can apply to number and string types. | ||
min = 0 | ||
max = 10 | ||
} | ||
} |
Oops, something went wrong.