File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
examples/resources/coder_parameter Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ data "coder_parameter" "fairy_tale" {
7575 name = " Fairy Tale"
7676 type = " string"
7777 mutable = true
78+ default = " Hansel and Gretel"
7879 ephemeral = true
7980}
8081
Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ func parameterDataSource() *schema.Resource {
134134 return diag .Errorf ("parameter can't be immutable and ephemeral" )
135135 }
136136
137+ if ! parameter .Optional && parameter .Ephemeral {
138+ return diag .Errorf ("ephemeral parameter requires the default property" )
139+ }
140+
137141 if len (parameter .Validation ) == 1 {
138142 validation := & parameter .Validation [0 ]
139143 err = validation .Valid (parameter .Type , value )
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ func TestParameter(t *testing.T) {
3131 EOT
3232 mutable = true
3333 icon = "/icon/region.svg"
34+ default = "us-east1-a"
3435 option {
3536 name = "US Central"
3637 value = "us-central1-a"
@@ -65,6 +66,7 @@ func TestParameter(t *testing.T) {
6566 "option.1.icon" : "/icon/east.svg" ,
6667 "option.1.description" : "Select for east!" ,
6768 "order" : "5" ,
69+ "default" : "us-east1-a" ,
6870 "ephemeral" : "true" ,
6971 } {
7072 require .Equal (t , value , attrs [key ])
@@ -558,11 +560,23 @@ data "coder_parameter" "region" {
558560 data "coder_parameter" "region" {
559561 name = "Region"
560562 type = "string"
563+ default = "abc"
561564 mutable = false
562565 ephemeral = true
563566 }
564567 ` ,
565568 ExpectError : regexp .MustCompile ("parameter can't be immutable and ephemeral" ),
569+ }, {
570+ Name : "RequiredEphemeralError" ,
571+ Config : `
572+ data "coder_parameter" "region" {
573+ name = "Region"
574+ type = "string"
575+ mutable = true
576+ ephemeral = true
577+ }
578+ ` ,
579+ ExpectError : regexp .MustCompile ("ephemeral parameter requires the default property" ),
566580 }} {
567581 tc := tc
568582 t .Run (tc .Name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments