8000 apply default form_type to state · coder/terraform-provider-coder@19d6749 · GitHub
[go: up one dir, main page]

Skip to content

Commit 19d6749

Browse files
committed
apply default form_type to state
1 parent 4bafcc6 commit 19d6749

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

provider/parameter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ func parameterDataSource() *schema.Resource {
155155
// Validate options
156156
var optionType string
157157
optionType, parameter.FormType, err = ValidateFormType(parameter.Type, len(parameter.Option), parameter.FormType)
158+
if err != nil {
159+
return diag.FromErr(err)
160+
}
161+
rd.Set("form_type", parameter.FormType)
158162

159163
if len(parameter.Option) > 0 {
160164
names := map[string]interface{}{}

provider/parameter_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestParameter(t *testing.T) {
2727
name = "region"
2828
display_name = "Region"
2929
type = "string"
30+
form_type = "radio"
3031
description = <<-EOT
3132
# Select the machine image
3233
See the [registry](https://container.registry.blah/namespace) for options.
@@ -56,6 +57,7 @@ func TestParameter(t *testing.T) {
5657
"name": "region",
5758
"display_name": "Region",
5859
"type": "string",
60+
"form_type": "radio",
5961
"description": "# Select the machine image\nSee the [registry](https://container.registry.blah/namespace) for options.\n",
6062
"mutable": "true",
6163
"icon": "/icon/region.svg",
@@ -137,6 +139,7 @@ func TestParameter(t *testing.T) {
137139
for key, expected := range map[string]string{
138140
"name": "Region",
139141
"type": "number",
142+
"form_type": "input",
140143
"validation.#": "1",
141144
"default": "2",
142145
"validation.0.min": "1",

0 commit comments

Comments
 (0)
0