File tree 3 files changed +19
-0
lines changed
examples/resources/coder_parameter
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" {
75
75
name = " Fairy Tale"
76
76
type = " string"
77
77
mutable = true
78
+ default = " Hansel and Gretel"
78
79
ephemeral = true
79
80
}
80
81
Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ func parameterDataSource() *schema.Resource {
134
134
return diag .Errorf ("parameter can't be immutable and ephemeral" )
135
135
}
136
136
137
+ if ! parameter .Optional && parameter .Ephemeral {
138
+ return diag .Errorf ("ephemeral parameter requires the default property" )
139
+ }
140
+
137
141
if len (parameter .Validation ) == 1 {
138
142
validation := & parameter .Validation [0 ]
139
143
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) {
31
31
EOT
32
32
mutable = true
33
33
icon = "/icon/region.svg"
34
+ default = "us-east1-a"
34
35
option {
35
36
name = "US Central"
36
37
value = "us-central1-a"
@@ -65,6 +66,7 @@ func TestParameter(t *testing.T) {
65
66
"option.1.icon" : "/icon/east.svg" ,
66
67
"option.1.description" : "Select for east!" ,
67
68
"order" : "5" ,
69
+ "default" : "us-east1-a" ,
68
70
"ephemeral" : "true" ,
69
71
} {
70
72
require .Equal (t , value , attrs [key ])
@@ -558,11 +560,23 @@ data "coder_parameter" "region" {
558
560
data "coder_parameter" "region" {
559
561
name = "Region"
560
562
type = "string"
563
+ default = "abc"
561
564
mutable = false
562
565
ephemeral = true
563
566
}
564
567
` ,
565
568
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" ),
566
580
}} {
567
581
tc := tc
568
582
t .Run (tc .Name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments