Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/data-sources/parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ data "coder_parameter" "home_volume_size" {
- `ephemeral` (Boolean) The value of an ephemeral parameter will not be preserved between consecutive workspace builds.
- `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))
- `option` (Block List) 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))
Expand Down
1 change: 0 additions & 1 deletion provider/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ func parameterDataSource() *schema.Resource {
Description: "Each `option` block defines a value for a user to select from.",
ForceNew: true,
Optional: true,
MaxItems: 64,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Expand Down
42 changes: 42 additions & 0 deletions provider/parameter_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package provider_test

import (
"fmt"
"regexp"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -816,3 +818,43 @@ func TestValueValidatesType(t *testing.T) {
})
}
}

func TestParameterWithManyOptions(t *testing.T) {
t.Parallel()

const maxItemsInTest = 1024

var options strings.Builder
for i := 0; i < maxItemsInTest; i++ {
_, _ = options.WriteString(fmt.Sprintf(`option {
name = "%d"
value = "%d"
}
`, i, i))
}

resource.Test(t, resource.TestCase{
ProviderFactories: coderFactory(),
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: fmt.Sprintf(`data "coder_parameter" "region" {
name = "Region"
type = "string"
%s
}`, options.String()),
Check: func(state *terraform.State) error {
require.Len(t, state.Modules, 1)
require.Len(t, state.Modules[0].Resources, 1)
param := state.Modules[0].Resources["data.coder_parameter.region"]

for i := 0; i < maxItemsInTest; i++ {
name, _ := param.Primary.Attributes[fmt.Sprintf("option.%d.name", i)]
value, _ := param.Primary.Attributes[fmt.Sprintf("option.%d.value", i)]
require.Equal(t, fmt.Sprintf("%d", i), name)
require.Equal(t, fmt.Sprintf("%d", i), value)
}
return nil
},
}},
})
}
Loading