@@ -258,32 +258,14 @@ func decodeBodyToMap(body hcl.Body, ctx *hcl.EvalContext, v reflect.Value) hcl.D
258258}
259259
260260func decodeBlockToValue (block * hcl.Block , ctx * hcl.EvalContext , v reflect.Value ) hcl.Diagnostics {
261- var diags hcl.Diagnostics
262-
263- ty := v .Type ()
264-
265- switch {
266- case blockType .AssignableTo (ty ):
267- v .Elem ().Set (reflect .ValueOf (block ))
268- case bodyType .AssignableTo (ty ):
269- v .Elem ().Set (reflect .ValueOf (block .Body ))
270- case attrsType .AssignableTo (ty ):
271- attrs , attrsDiags := block .Body .JustAttributes ()
272- if len (attrsDiags ) > 0 {
273- diags = append (diags , attrsDiags ... )
274- }
275- v .Elem ().Set (reflect .ValueOf (attrs ))
276- default :
277- diags = append (diags , decodeBodyToValue (block .Body , ctx , v )... )
261+ diags := decodeBodyToValue (block .Body , ctx , v )
278262
279- if len (block .Labels ) > 0 {
280- blockTags := getFieldTags (ty )
281- for li , lv := range block .Labels {
282- lfieldIdx := blockTags .Labels [li ].FieldIndex
283- v .Field (lfieldIdx ).Set (reflect .ValueOf (lv ))
284- }
263+ if len (block .Labels ) > 0 {
264+ blockTags := getFieldTags (v .Type ())
265+ for li , lv := range block .Labels {
266+ lfieldIdx := blockTags .Labels [li ].FieldIndex
267+ v .Field (lfieldIdx ).Set (reflect .ValueOf (lv ))
285268 }
286-
287269 }
288270
289271 return diags
0 commit comments