diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 5785cb57f4ac8..9e253a4f92fff 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -8044,7 +8044,8 @@ const docTemplate = `{ "enum": [ "string", "number", - "bool" + "bool", + "list(string)" ] }, "validation_error": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index dc7a9dd435e4a..55ac7533a03c7 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -7235,7 +7235,7 @@ }, "type": { "type": "string", - "enum": ["string", "number", "bool"] + "enum": ["string", "number", "bool", "list(string)"] }, "validation_error": { "type": "string" diff --git a/coderd/workspacebuilds_test.go b/coderd/workspacebuilds_test.go index 450fdc9fc5962..4db53a3a48201 100644 --- a/coderd/workspacebuilds_test.go +++ b/coderd/workspacebuilds_test.go @@ -793,12 +793,16 @@ func TestWorkspaceBuildValidateRichParameters(t *testing.T) { boolParameterName = "bool_parameter" boolParameterValue = "true" + + listOfStringsParameterName = "list_of_strings_parameter" + listOfStringsParameterValue = `["a","b","c"]` ) initialBuildParameters := []codersdk.WorkspaceBuildParameter{ {Name: stringParameterName, Value: stringParameterValue}, {Name: numberParameterName, Value: numberParameterValue}, {Name: boolParameterName, Value: boolParameterValue}, + {Name: listOfStringsParameterName, Value: listOfStringsParameterValue}, } prepareEchoResponses := func(richParameters []*proto.RichParameter) *echo.Responses { @@ -902,6 +906,10 @@ func TestWorkspaceBuildValidateRichParameters(t *testing.T) { {Name: boolParameterName, Type: "bool", Mutable: true}, } + listOfStringsRichParameters := []*proto.RichParameter{ + {Name: listOfStringsParameterName, Type: "list(string)", Mutable: true}, + } + tests := []struct { parameterName string value string @@ -930,6 +938,11 @@ func TestWorkspaceBuildValidateRichParameters(t *testing.T) { {boolParameterName, "true", true, boolRichParameters}, {boolParameterName, "false", true, boolRichParameters}, {boolParameterName, "cat", false, boolRichParameters}, + + {listOfStringsParameterName, `[]`, true, listOfStringsRichParameters}, + {listOfStringsParameterName, `["aa"]`, true, listOfStringsRichParameters}, + {listOfStringsParameterName, `["aa]`, false, listOfStringsRichParameters}, + {listOfStringsParameterName, ``, false, listOfStringsRichParameters}, } for _, tc := range tests { diff --git a/codersdk/richparameters.go b/codersdk/richparameters.go index cad8c4da81fdc..b40ecaba112a3 100644 --- a/codersdk/richparameters.go +++ b/codersdk/richparameters.go @@ -113,5 +113,6 @@ func validationEnabled(param TemplateVersionParameter) bool { return len(param.ValidationRegex) > 0 || (param.ValidationMin != 0 && param.ValidationMax != 0) || len(param.ValidationMonotonic) > 0 || - param.Type == "bool" // boolean type doesn't have any custom validation rules, but the value must be checked (true/false). + param.Type == "bool" || // boolean type doesn't have any custom validation rules, but the value must be checked (true/false). + param.Type == "list(string)" // list(string) type doesn't have special validation, but we need to check if this is a correct list. } diff --git a/codersdk/templateversions.go b/codersdk/templateversions.go index 639e374a640e0..80a1a14776440 100644 --- a/codersdk/templateversions.go +++ b/codersdk/templateversions.go @@ -43,7 +43,7 @@ type TemplateVersionParameter struct { Name string `json:"name"` Description string `json:"description"` DescriptionPlaintext string `json:"description_plaintext"` - Type string `json:"type" enums:"string,number,bool"` + Type string `json:"type" enums:"string,number,bool,list(string)"` Mutable bool `json:"mutable"` DefaultValue string `json:"default_value"` Icon string `json:"icon"` diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 7ee906d6195b7..7090c3d602ccd 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -3777,13 +3777,14 @@ Parameter represents a set value for the scope. #### Enumerated Values -| Property | Value | -| ---------------------- | ------------ | -| `type` | `string` | -| `type` | `number` | -| `type` | `bool` | -| `validation_monotonic` | `increasing` | -| `validation_monotonic` | `decreasing` | +| Property | Value | +| ---------------------- | -------------- | +| `type` | `string` | +| `type` | `number` | +| `type` | `bool` | +| `type` | `list(string)` | +| `validation_monotonic` | `increasing` | +| `validation_monotonic` | `decreasing` | ## codersdk.TemplateVersionParameterOption diff --git a/docs/api/templates.md b/docs/api/templates.md index b0d2b74f9b426..d3397e02d8209 100644 --- a/docs/api/templates.md +++ b/docs/api/templates.md @@ -2266,13 +2266,14 @@ Status Code **200** #### Enumerated Values -| Property | Value | -| ---------------------- | ------------ | -| `type` | `string` | -| `type` | `number` | -| `type` | `bool` | -| `validation_monotonic` | `increasing` | -| `validation_monotonic` | `decreasing` | +| Property | Value | +| ---------------------- | -------------- | +| `type` | `string` | +| `type` | `number` | +| `type` | `bool` | +| `type` | `list(string)` | +| `validation_monotonic` | `increasing` | +| `validation_monotonic` | `decreasing` | To perform this operation, you must be authenticated. [Learn more](authentication.md). diff --git a/go.mod b/go.mod index 317b857bd2fc3..3b716322ad39b 100644 --- a/go.mod +++ b/go.mod @@ -75,7 +75,7 @@ require ( github.com/codeclysm/extract v2.2.0+incompatible github.com/coder/flog v1.0.0 github.com/coder/retry v1.3.1-0.20230210155434-e90a2e1e091d - github.com/coder/terraform-provider-coder v0.6.17 + github.com/coder/terraform-provider-coder v0.6.20 github.com/coreos/go-oidc/v3 v3.4.0 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/creack/pty v1.1.18 @@ -183,9 +183,6 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/google/flatbuffers v23.1.21+incompatible // indirect github.com/h2non/filetype v1.1.3 // indirect - github.com/hashicorp/go-plugin v1.4.4 // indirect - github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect - github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/juju/errors v1.0.0 // indirect github.com/mattn/go-localereader v0.0.1 // indirect @@ -193,7 +190,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/muesli/cancelreader v0.2.2 // indirect - github.com/oklog/run v1.0.0 // indirect ) require ( diff --git a/go.sum b/go.sum index 3b3f19badf7ce..71e522a9e864e 100644 --- a/go.sum +++ b/go.sum @@ -376,24 +376,10 @@ github.com/coder/retry v1.3.1-0.20230210155434-e90a2e1e091d h1:09JG37IgTB6n3ouX9 github.com/coder/retry v1.3.1-0.20230210155434-e90a2e1e091d/go.mod h1:r+1J5i/989wt6CUeNSuvFKKA9hHuKKPMxdzDbTuvwwk= github.com/coder/ssh v0.0.0-20220811105153-fcea99919338 h1:tN5GKFT68YLVzJoA8AHuiMNJ0qlhoD3pGN3JY9gxSko= github.com/coder/ssh v0.0.0-20220811105153-fcea99919338/go.mod h1:ZSS+CUoKHDrqVakTfTWUlKSr9MtMFkC4UvtQKD7O914= -github.com/coder/tailscale v1.1.1-0.20230307022319-1e5e724a3949 h1:8WfMfRTDaEpnmhCJWfFQ7JHz19GyP+EgFgLGu5ngdek= -github.com/coder/tailscale v1.1.1-0.20230307022319-1e5e724a3949/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA= -github.com/coder/tailscale v1.1.1-0.20230313184322-307d4b9ef4e1 h1:kOh+1rBcbahdodSiNBioO4g47m3Ef8CagNEX8U7/RyY= -github.com/coder/tailscale v1.1.1-0.20230313184322-307d4b9ef4e1/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA= -github.com/coder/tailscale v1.1.1-0.20230313192237-8d691a009b20 h1:FFPv3xLsAT+n8chkePxB/VwqFwn4NL8GV8Lk97efUP0= -github.com/coder/tailscale v1.1.1-0.20230313192237-8d691a009b20/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA= -github.com/coder/tailscale v1.1.1-0.20230313194848-e281f646c460 h1:WYnHzxQ1DsgDYyyS6i8tgdpjiwS1LrXJjwXcOVkU/3g= -github.com/coder/tailscale v1.1.1-0.20230313194848-e281f646c460/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA= -github.com/coder/tailscale v1.1.1-0.20230313195101-c6534848756b h1:3xWbBCpQ+CqVP2Myh1YhCw8cJbMi6mjkDl4/x6YkiUw= -github.com/coder/tailscale v1.1.1-0.20230313195101-c6534848756b/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA= -github.com/coder/tailscale v1.1.1-0.20230314021518-0cda9db154be h1:b0ZTDPpV/fAdkuS/V59cawnq+5vcXzkvXPMG/eZcRx0= -github.com/coder/tailscale v1.1.1-0.20230314021518-0cda9db154be/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA= github.com/coder/tailscale v1.1.1-0.20230314023417-d9efcc0ac972 h1:193YGsJz8hc4yxqAclE36paKl+9CQ6KGLgdleIguCVE= github.com/coder/tailscale v1.1.1-0.20230314023417-d9efcc0ac972/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA= -github.com/coder/terraform-provider-coder v0.6.15 h1:Llvh4RwxSQ/goy7ToTOeHf3tdEz+79qbyOh61hNnJs0= -github.com/coder/terraform-provider-coder v0.6.15/go.mod h1:UIfU3bYNeSzJJvHyJ30tEKjD6Z9utloI+HUM/7n94CY= -github.com/coder/terraform-provider-coder v0.6.17 h1:YvjM5nQx5RO+gXsYIv++CkiWCuJueQdJaPrsjnkZ4XQ= -github.com/coder/terraform-provider-coder v0.6.17/go.mod h1:UIfU3bYNeSzJJvHyJ30tEKjD6Z9utloI+HUM/7n94CY= +github.com/coder/terraform-provider-coder v0.6.20 h1:bVyITX9JlbnGzKzTj0qi/JziUCGqD2DiN3cXaWyDcxE= +github.com/coder/terraform-provider-coder v0.6.20/go.mod h1:UIfU3bYNeSzJJvHyJ30tEKjD6Z9utloI+HUM/7n94CY= github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE= github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU= github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU= @@ -1039,7 +1025,6 @@ github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.4.4 h1:NVdrSdFRt3SkZtNckJ6tog7gbpRrcbOjQi/rgF7JYWQ= -github.com/hashicorp/go-plugin v1.4.4/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-reap v0.0.0-20170704170343-bf58d8a43e7b h1:3GrpnZQBxcMj1gCXQLelfjCT1D5MPGTuGMKHVzSIH6A= github.com/hashicorp/go-reap v0.0.0-20170704170343-bf58d8a43e7b/go.mod h1:qIFzeFcJU3OIFk/7JreWXcUjFmcCaeHTH9KoNyHYVCs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= @@ -1050,7 +1035,6 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= @@ -1087,9 +1071,7 @@ github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfD github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0 h1:+KxZULPsbjpAVoP0WNj/8aVW6EqpcX5JcUcQ5wl7Da4= github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0/go.mod h1:DwGJG3KNxIPluVk6hexvDfYR/MS/eKGpiztJoT3Bbbw= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= -github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= github.com/hashicorp/yamux v0.0.0-20220718163420-dd80a7ee44ce h1:7FO+LmZwiG/eDsBWo50ZeqV5PoH0gwiM1mxFajXAkas= github.com/hashicorp/yamux v0.0.0-20220718163420-dd80a7ee44ce/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= @@ -1513,7 +1495,6 @@ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= @@ -2182,7 +2163,6 @@ golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191007182048-72f939374954/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=