Skip to content

feat: add order to coder_parameter #134

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

Merged
merged 5 commits into from
Jun 28, 2023
Merged
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
2 changes: 0 additions & 2 deletions docs/data-sources/git_auth.md
Original file line number Diff line number Diff line change
@@ -46,5 +46,3 @@ EOF
### Read-Only

- `access_token` (String) The access token returned by the git authentication provider. This can be used to pre-authenticate command-line tools.


3 changes: 1 addition & 2 deletions docs/data-sources/parameter.md
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ Use this data source to configure editable options for workspaces.
- `legacy_variable_name` (String, Deprecated) Name of the legacy Terraform variable. Coder will use it to lookup the variable value.
- `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))
- `order` (Number) The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order).
- `type` (String) The type of this parameter. Must be one of: "number", "string", "bool", or "list(string)".
- `validation` (Block List, Max: 1) Validate the input of a parameter. (see [below for nested schema](#nestedblock--validation))

@@ -67,5 +68,3 @@ Read-Only:

- `max_disabled` (Boolean) Helper field to check if max is present
- `min_disabled` (Boolean) Helper field to check if min is present


2 changes: 0 additions & 2 deletions docs/data-sources/provisioner.md
Original file line number Diff line number Diff line change
@@ -20,5 +20,3 @@ Use this data source to get information about the Coder provisioner.
- `arch` (String) The architecture of the host. This exposes `runtime.GOARCH` (see https://pkg.go.dev/runtime#pkg-constants).
- `id` (String) The ID of this resource.
- `os` (String) The operating system of the host. This exposes `runtime.GOOS` (see https://pkg.go.dev/runtime#pkg-constants).


2 changes: 0 additions & 2 deletions docs/data-sources/workspace.md
Original file line number Diff line number Diff line change
@@ -37,5 +37,3 @@ resource "kubernetes_pod" "dev" {
- `owner_session_token` (String) Session token for interfacing with a Coder deployment. It is regenerated everytime a workspace is started.
- `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
- `transition` (String) Either "start" or "stop". Use this to start/stop resources with "count".


2 changes: 0 additions & 2 deletions docs/resources/agent.md
Original file line number Diff line number Diff line change
@@ -79,5 +79,3 @@ Optional:

- `display_name` (String) The user-facing name of this value.
- `timeout` (Number) The maximum time the command is allowed to run in seconds.


2 changes: 0 additions & 2 deletions docs/resources/agent_instance.md
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.


2 changes: 0 additions & 2 deletions docs/resources/app.md
Original file line number Diff line number Diff line change
@@ -90,5 +90,3 @@ Required:
- `interval` (Number) Duration in seconds to wait between healthcheck requests.
- `threshold` (Number) Number of consecutive heathcheck failures before returning an unhealthy status.
- `url` (String) HTTP address used determine the application readiness. A successful health check is a HTTP response code less than 500 returned before healthcheck.interval seconds.


2 changes: 0 additions & 2 deletions docs/resources/metadata.md
Original file line number Diff line number Diff line change
@@ -80,5 +80,3 @@ Optional:
Read-Only:

- `is_null` (Boolean)


2 changes: 2 additions & 0 deletions examples/resources/coder_parameter/resource.tf
Original file line number Diff line number Diff line change
@@ -45,12 +45,14 @@ data "coder_parameter" "cores" {
type = "number"
icon = "/icon/cpu.svg"
default = 3
order = 10
}

data "coder_parameter" "disk_size" {
name = "Disk Size"
type = "number"
default = "5"
order = 8
validation {
# This can apply to number.
min = 0
9 changes: 9 additions & 0 deletions provider/parameter.go
Original file line number Diff line number Diff line change
@@ -57,6 +57,8 @@ type Parameter struct {
Validation []Validation
Optional bool

Order int

LegacyVariableName string `mapstructure:"legacy_variable_name"`
LegacyVariable string `mapstructure:"legacy_variable"`
}
@@ -90,6 +92,7 @@ func parameterDataSource() *schema.Resource {
Option interface{}
Validation interface{}
Optional interface{}
Order interface{}

LegacyVariableName interface{}
LegacyVariable interface{}
@@ -122,6 +125,7 @@ func parameterDataSource() *schema.Resource {
rd.Set("optional", val)
return val
}(),
Order: rd.Get("order"),
LegacyVariableName: rd.Get("legacy_variable_name"),
LegacyVariable: rd.Get("legacy_variable"),
}, &parameter)
@@ -331,6 +335,11 @@ func parameterDataSource() *schema.Resource {
Computed: true,
Description: "Whether this value is optional.",
},
"order": {
Type: schema.TypeInt,
Optional: true,
Description: "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order).",
},
"legacy_variable_name": {
Type: schema.TypeString,
Optional: true,
2 changes: 2 additions & 0 deletions provider/parameter_test.go
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ func TestParameter(t *testing.T) {
icon = "/icon/east.svg"
description = "Select for east!"
}
order = 5
}
`,
Check: func(state *terraform.ResourceState) {
@@ -62,6 +63,7 @@ func TestParameter(t *testing.T) {
"option.1.value": "us-east1-a",
"option.1.icon": "/icon/east.svg",
"option.1.description": "Select for east!",
"order": "5",
} {
require.Equal(t, value, attrs[key])
}