Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: support unlimited parameter options#345

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

Merged
mtojek merged 2 commits intomainfrom161-no-more-block
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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 deletiondocs/data-sources/parameter.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionprovider/parameter.go
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsprovider/parameter_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package provider_test

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

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp