diff --git a/cmd/utils.go b/cmd/utils.go index 3c21fada..cc79594d 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -512,7 +512,7 @@ func readUpdateCommands(args []string, expectedArgs int, badArgsMessage string, log.Debug("path %v", args[expectedArgs-2]) log.Debug("Value %v", args[expectedArgs-1]) value := valueParser.Parse(args[expectedArgs-1], customTag, customStyle, anchorName, makeAlias) - updateCommands[0] = yqlib.UpdateCommand{Command: "update", Path: args[expectedArgs-2], Value: value, Overwrite: true, DontUpdateComments: true} + updateCommands[0] = yqlib.UpdateCommand{Command: "update", Path: args[expectedArgs-2], Value: value, Overwrite: true, CommentsMergeStrategy: yqlib.IgnoreCommentsMergeStrategy} } else if len(args) == expectedArgs-1 && allowNoValue { // don't update the value updateCommands = make([]yqlib.UpdateCommand, 1) diff --git a/pkg/yqlib/encoder.go b/pkg/yqlib/encoder.go index fbacb963..5694722c 100644 --- a/pkg/yqlib/encoder.go +++ b/pkg/yqlib/encoder.go @@ -59,13 +59,13 @@ type jsonEncoder struct { } func mapKeysToStrings(node *yaml.Node) { - + if node.Kind == yaml.MappingNode { for index, child := range node.Content { - if index % 2 == 0 { // its a map key + if index%2 == 0 { // its a map key child.Tag = "!!str" } - } + } } for _, child := range node.Content { diff --git a/pkg/yqlib/update_navigation_strategy.go b/pkg/yqlib/update_navigation_strategy.go index c71e4756..b5b0e750 100644 --- a/pkg/yqlib/update_navigation_strategy.go +++ b/pkg/yqlib/update_navigation_strategy.go @@ -29,7 +29,7 @@ func UpdateNavigationStrategy(updateCommand UpdateCommand, autoCreate bool) Navi } node.Anchor = changesToApply.Anchor node.Alias = changesToApply.Alias - if !updateCommand.DontUpdateComments { + if updateCommand.CommentsMergeStrategy != IgnoreCommentsMergeStrategy { node.HeadComment = changesToApply.HeadComment node.LineComment = changesToApply.LineComment node.FootComment = changesToApply.FootComment