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":
|
case "object":
|
||||||
return decodeObjectSpec(block.Body)
|
return decodeObjectSpec(block.Body)
|
||||||
|
|
||||||
|
case "array":
|
||||||
|
return decodeArraySpec(block.Body)
|
||||||
|
|
||||||
case "attr":
|
case "attr":
|
||||||
return decodeAttrSpec(block.Body, impliedName)
|
return decodeAttrSpec(block.Body, impliedName)
|
||||||
|
|
||||||
@ -112,6 +115,19 @@ func decodeObjectSpec(body hcl.Body) (hcldec.Spec, hcl.Diagnostics) {
|
|||||||
return spec, diags
|
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) {
|
func decodeAttrSpec(body hcl.Body, impliedName string) (hcldec.Spec, hcl.Diagnostics) {
|
||||||
type content struct {
|
type content struct {
|
||||||
Name *string `hcl:"name"`
|
Name *string `hcl:"name"`
|
||||||
@ -429,7 +445,7 @@ var errSpec = &hcldec.LiteralSpec{
|
|||||||
|
|
||||||
var specBlockTypes = []string{
|
var specBlockTypes = []string{
|
||||||
"object",
|
"object",
|
||||||
"tuple",
|
"array",
|
||||||
|
|
||||||
"literal",
|
"literal",
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user