(block *hcl.Block, ctx *hcl.EvalContext, v reflect.Value)
| 274 | } |
| 275 | |
| 276 | func decodeBlockToValue(block *hcl.Block, ctx *hcl.EvalContext, v reflect.Value) hcl.Diagnostics { |
| 277 | diags := decodeBodyToValue(block.Body, ctx, v) |
| 278 | |
| 279 | blockTags := getFieldTags(v.Type()) |
| 280 | for li, lv := range block.Labels { |
| 281 | lfieldIdx := blockTags.Labels[li].FieldIndex |
| 282 | lfieldName := blockTags.Labels[li].Name |
| 283 | |
| 284 | v.Field(lfieldIdx).Set(reflect.ValueOf(lv)) |
| 285 | |
| 286 | if ix, exists := blockTags.LabelRange[lfieldName]; exists { |
| 287 | v.Field(ix).Set(reflect.ValueOf(block.LabelRanges[li])) |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | if blockTags.TypeRange != nil { |
| 292 | v.Field(*blockTags.TypeRange).Set(reflect.ValueOf(block.TypeRange)) |
| 293 | } |
| 294 | |
| 295 | if blockTags.DefRange != nil { |
| 296 | v.Field(*blockTags.DefRange).Set(reflect.ValueOf(block.DefRange)) |
| 297 | } |
| 298 | |
| 299 | return diags |
| 300 | } |
| 301 | |
| 302 | // DecodeExpression extracts the value of the given expression into the given |
| 303 | // value. This value must be something that gocty is able to decode into, |
no test coverage detected