(body hcl.Body, impliedName string)
| 445 | } |
| 446 | |
| 447 | func decodeBlockAttrsSpec(body hcl.Body, impliedName string) (hcldec.Spec, hcl.Diagnostics) { |
| 448 | type content struct { |
| 449 | TypeName *string `hcl:"block_type"` |
| 450 | ElementType hcl.Expression `hcl:"element_type"` |
| 451 | Required *bool `hcl:"required"` |
| 452 | } |
| 453 | |
| 454 | var args content |
| 455 | diags := gohcl.DecodeBody(body, nil, &args) |
| 456 | if diags.HasErrors() { |
| 457 | return errSpec, diags |
| 458 | } |
| 459 | |
| 460 | spec := &hcldec.BlockAttrsSpec{ |
| 461 | TypeName: impliedName, |
| 462 | } |
| 463 | |
| 464 | if args.Required != nil { |
| 465 | spec.Required = *args.Required |
| 466 | } |
| 467 | if args.TypeName != nil { |
| 468 | spec.TypeName = *args.TypeName |
| 469 | } |
| 470 | |
| 471 | var typeDiags hcl.Diagnostics |
| 472 | spec.ElementType, typeDiags = evalTypeExpr(args.ElementType) |
| 473 | diags = append(diags, typeDiags...) |
| 474 | |
| 475 | if spec.TypeName == "" { |
| 476 | diags = append(diags, &hcl.Diagnostic{ |
| 477 | Severity: hcl.DiagError, |
| 478 | Summary: "Missing block_type in block_attrs spec", |
| 479 | Detail: "The block_type attribute is required, to specify the block type name that is expected in an input HCL file.", |
| 480 | Subject: body.MissingItemRange().Ptr(), |
| 481 | }) |
| 482 | return errSpec, diags |
| 483 | } |
| 484 | |
| 485 | return spec, diags |
| 486 | } |
| 487 | |
| 488 | func decodeLiteralSpec(body hcl.Body) (hcldec.Spec, hcl.Diagnostics) { |
| 489 | type content struct { |
no test coverage detected