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

Commita9b64aa

Browse files
authored
fix: support unlimited parameter options (#345)
1 parent4b3fc65 commita9b64aa

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

‎docs/data-sources/parameter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ data "coder_parameter" "home_volume_size" {
147147
-`ephemeral` (Boolean) The value of an ephemeral parameter will not be preserved between consecutive workspace builds.
148148
-`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>"`.
149149
-`mutable` (Boolean) Whether this value can be changed after workspace creation. This can be destructive for values like region, so use with caution!
150-
-`option` (Block List, Max: 64) Each`option` block defines a value for a user to select from. (see[below for nested schema](#nestedblock--option))
150+
-`option` (Block List) Each`option` block defines a value for a user to select from. (see[below for nested schema](#nestedblock--option))
151151
-`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).
152152
-`type` (String) The type of this parameter. Must be one of:`"number"`,`"string"`,`"bool"`, or`"list(string)"`.
153153
-`validation` (Block List, Max: 1) Validate the input of a parameter. (see[below for nested schema](#nestedblock--validation))

‎provider/parameter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ func parameterDataSource() *schema.Resource {
237237
Description:"Each `option` block defines a value for a user to select from.",
238238
ForceNew:true,
239239
Optional:true,
240-
MaxItems:64,
241240
Elem:&schema.Resource{
242241
Schema:map[string]*schema.Schema{
243242
"name": {

‎provider/parameter_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package provider_test
22

33
import (
4+
"fmt"
45
"regexp"
6+
"strings"
57
"testing"
68

79
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -816,3 +818,43 @@ func TestValueValidatesType(t *testing.T) {
816818
})
817819
}
818820
}
821+
822+
funcTestParameterWithManyOptions(t*testing.T) {
823+
t.Parallel()
824+
825+
constmaxItemsInTest=1024
826+
827+
varoptions strings.Builder
828+
fori:=0;i<maxItemsInTest;i++ {
829+
_,_=options.WriteString(fmt.Sprintf(`option {
830+
name = "%d"
831+
value = "%d"
832+
}
833+
`,i,i))
834+
}
835+
836+
resource.Test(t, resource.TestCase{
837+
ProviderFactories:coderFactory(),
838+
IsUnitTest:true,
839+
Steps: []resource.TestStep{{
840+
Config:fmt.Sprintf(`data "coder_parameter" "region" {
841+
name = "Region"
842+
type = "string"
843+
%s
844+
}`,options.String()),
845+
Check:func(state*terraform.State)error {
846+
require.Len(t,state.Modules,1)
847+
require.Len(t,state.Modules[0].Resources,1)
848+
param:=state.Modules[0].Resources["data.coder_parameter.region"]
849+
850+
fori:=0;i<maxItemsInTest;i++ {
851+
name,_:=param.Primary.Attributes[fmt.Sprintf("option.%d.name",i)]
852+
value,_:=param.Primary.Attributes[fmt.Sprintf("option.%d.value",i)]
853+
require.Equal(t,fmt.Sprintf("%d",i),name)
854+
require.Equal(t,fmt.Sprintf("%d",i),value)
855+
}
856+
returnnil
857+
},
858+
}},
859+
})
860+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp