@@ -13,7 +13,7 @@ import (
1313 "github.com/coder/preview/hclext"
1414)
1515
16- func ParameterContextsEvalHook (input Input , diags hcl. Diagnostics ) func (ctx * tfcontext.Context , blocks terraform.Blocks , inputVars map [string ]cty.Value ) {
16+ func ParameterContextsEvalHook (input Input ) func (ctx * tfcontext.Context , blocks terraform.Blocks , inputVars map [string ]cty.Value ) {
1717 return func (ctx * tfcontext.Context , blocks terraform.Blocks , inputVars map [string ]cty.Value ) {
1818 data := blocks .OfType ("data" )
1919 for _ , block := range data {
@@ -26,16 +26,15 @@ func ParameterContextsEvalHook(input Input, diags hcl.Diagnostics) func(ctx *tfc
2626 }
2727
2828 name := block .NameLabel ()
29- var defDiags hcl.Diagnostics
3029 var value cty.Value
3130 pv , ok := input .RichParameterValue (name )
3231 if ok {
3332 // TODO: Handle non-string types
3433 value = pv .Value
3534 } else {
3635 // get the default value
37- value , defDiags = evaluateCoderParameterDefault ( block )
38- diags = diags . Extend ( defDiags )
36+ // TODO: Log any diags
37+ value , _ = evaluateCoderParameterDefault ( block )
3938 }
4039
4140 // Set the default value as the 'value' attribute
@@ -56,28 +55,16 @@ func evaluateCoderParameterDefault(b *terraform.Block) (cty.Value, hcl.Diagnosti
5655 //}
5756
5857 attributes := b .Attributes ()
59- if attributes == nil {
60- r := b .HCLBlock ().Body .MissingItemRange ()
61- return cty .NilVal , hcl.Diagnostics {
62- {
63- Severity : hcl .DiagWarning ,
64- Summary : "'coder_parameter' block has no attributes" ,
65- Detail : "No default value will be set for this paramete" ,
66- Subject : & r ,
67- },
68- }
69- }
70-
7158 var valType cty.Type
7259 var defaults * typeexpr.Defaults
73- // TODO: `"string"` fails, it should be `string`
60+
7461 typeAttr , exists := attributes ["type" ]
7562 if exists {
7663 ty , def , err := hclext .DecodeVarType (typeAttr .HCLAttribute ().Expr )
7764 if err != nil {
7865 return cty .NilVal , hcl.Diagnostics {
7966 {
80- Severity : hcl .DiagWarning ,
67+ Severity : hcl .DiagError ,
8168 Summary : fmt .Sprintf ("Decoding parameter type for %q" , b .FullName ()),
8269 Detail : err .Error (),
8370 Subject : & typeAttr .HCLAttribute ().Range ,
@@ -112,7 +99,7 @@ func evaluateCoderParameterDefault(b *terraform.Block) (cty.Value, hcl.Diagnosti
11299 if err != nil {
113100 return cty .NilVal , hcl.Diagnostics {
114101 {
115- Severity : hcl .DiagWarning ,
102+ Severity : hcl .DiagError ,
116103 Summary : "Converting default parameter value type" ,
117104 Detail : err .Error (),
118105 Subject : & def .HCLAttribute ().Range ,
0 commit comments