cmd/hcldec: decode "array" blocks
These were missed on the previous pass, causing a disagreement with the documentation.
This commit is contained in:
parent
ee147d9ee6
commit
f65a097d17
@ -64,6 +64,9 @@ func decodeSpecBlock(block *hcl.Block) (hcldec.Spec, hcl.Diagnostics) {
|
||||
case "object":
|
||||
return decodeObjectSpec(block.Body)
|
||||
|
||||
case "array":
|
||||
return decodeArraySpec(block.Body)
|
||||
|
||||
case "attr":
|
||||
return decodeAttrSpec(block.Body, impliedName)
|
||||
|
||||
@ -112,6 +115,19 @@ func decodeObjectSpec(body hcl.Body) (hcldec.Spec, hcl.Diagnostics) {
|
||||
return spec, diags
|
||||
}
|
||||
|
||||
func decodeArraySpec(body hcl.Body) (hcldec.Spec, hcl.Diagnostics) {
|
||||
content, diags := body.Content(specSchemaUnlabelled)
|
||||
|
||||
spec := make(hcldec.TupleSpec, 0, len(content.Blocks))
|
||||
for _, block := range content.Blocks {
|
||||
elemSpec, elemDiags := decodeSpecBlock(block)
|
||||
diags = append(diags, elemDiags...)
|
||||
spec = append(spec, elemSpec)
|
||||
}
|
||||
|
||||
return spec, diags
|
||||
}
|
||||
|
||||
func decodeAttrSpec(body hcl.Body, impliedName string) (hcldec.Spec, hcl.Diagnostics) {
|
||||
type content struct {
|
||||
Name *string `hcl:"name"`
|
||||
@ -429,7 +445,7 @@ var errSpec = &hcldec.LiteralSpec{
|
||||
|
||||
var specBlockTypes = []string{
|
||||
"object",
|
||||
"tuple",
|
||||
"array",
|
||||
|
||||
"literal",
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user