mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-04 11:25:37 +00:00
Update pkg/yqlib/encoder_hcl.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
effdfe1221
commit
154a4ace01
@ -325,26 +325,26 @@ func (he *hclEncoder) encodeNodeAttributes(body *hclwrite.Body, node *CandidateN
|
|||||||
key := keyNode.Value
|
key := keyNode.Value
|
||||||
|
|
||||||
if valueNode.Kind == MappingNode && valueNode.Style != FlowStyle {
|
if valueNode.Kind == MappingNode && valueNode.Style != FlowStyle {
|
||||||
if labels, bodyNode, ok := extractBlockLabels(valueNode); ok {
|
if labels, bodyNode, ok := extractBlockLabels(valueNode); ok {
|
||||||
if len(labels) > 1 && mappingChildrenAllMappings(bodyNode) {
|
if len(labels) > 1 && mappingChildrenAllMappings(bodyNode) {
|
||||||
primaryLabels := labels[:len(labels)-1]
|
primaryLabels := labels[:len(labels)-1]
|
||||||
nestedType := labels[len(labels)-1]
|
nestedType := labels[len(labels)-1]
|
||||||
block := body.AppendNewBlock(key, primaryLabels)
|
block := body.AppendNewBlock(key, primaryLabels)
|
||||||
if handled, err := he.encodeMappingChildrenAsBlocks(block.Body(), nestedType, bodyNode); err != nil {
|
if handled, err := he.encodeMappingChildrenAsBlocks(block.Body(), nestedType, bodyNode); err != nil {
|
||||||
return err
|
|
||||||
} else if !handled {
|
|
||||||
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
block := body.AppendNewBlock(key, labels)
|
|
||||||
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
|
|
||||||
return err
|
return err
|
||||||
|
} else if !handled {
|
||||||
|
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
block := body.AppendNewBlock(key, labels)
|
||||||
|
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
if handled, err := he.encodeMappingChildrenAsBlocks(body, key, valueNode); err != nil {
|
if handled, err := he.encodeMappingChildrenAsBlocks(body, key, valueNode); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if handled {
|
} else if handled {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user