Skip to content

Commit a315039

Browse files
mikefarahCopilot
andauthored
Update pkg/yqlib/encoder_hcl.go
Co-authored-by: Copilot <[email protected]>
1 parent c7c5a47 commit a315039

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

pkg/yqlib/encoder_hcl.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,26 +325,26 @@ func (he *hclEncoder) encodeNodeAttributes(body *hclwrite.Body, node *CandidateN
325325
key := keyNode.Value
326326

327327
if valueNode.Kind == MappingNode && valueNode.Style != FlowStyle {
328-
if labels, bodyNode, ok := extractBlockLabels(valueNode); ok {
329-
if len(labels) > 1 && mappingChildrenAllMappings(bodyNode) {
330-
primaryLabels := labels[:len(labels)-1]
331-
nestedType := labels[len(labels)-1]
332-
block := body.AppendNewBlock(key, primaryLabels)
333-
if handled, err := he.encodeMappingChildrenAsBlocks(block.Body(), nestedType, bodyNode); err != nil {
328+
if labels, bodyNode, ok := extractBlockLabels(valueNode); ok {
329+
if len(labels) > 1 && mappingChildrenAllMappings(bodyNode) {
330+
primaryLabels := labels[:len(labels)-1]
331+
nestedType := labels[len(labels)-1]
332+
block := body.AppendNewBlock(key, primaryLabels)
333+
if handled, err := he.encodeMappingChildrenAsBlocks(block.Body(), nestedType, bodyNode); err != nil {
334+
return err
335+
} else if !handled {
336+
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
334337
return err
335-
} else if !handled {
336-
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
337-
return err
338-
}
339338
}
340-
continue
341-
}
342-
block := body.AppendNewBlock(key, labels)
343-
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
344-
return err
345339
}
346340
continue
347341
}
342+
block := body.AppendNewBlock(key, labels)
343+
if err := he.encodeNodeAttributes(block.Body(), bodyNode); err != nil {
344+
return err
345+
}
346+
continue
347+
}
348348
if handled, err := he.encodeMappingChildrenAsBlocks(body, key, valueNode); err != nil {
349349
return err
350350
} else if handled {

0 commit comments

Comments
 (0)