diff --git a/pkg/yqlib/operator_anchors_aliases.go b/pkg/yqlib/operator_anchors_aliases.go index 9ad74b2f..cd1752e9 100644 --- a/pkg/yqlib/operator_anchors_aliases.go +++ b/pkg/yqlib/operator_anchors_aliases.go @@ -6,6 +6,8 @@ import ( "slices" ) +var showMergeAnchorToSpecWarning = true + func assignAliasOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { log.Debugf("AssignAlias operator!") @@ -159,8 +161,9 @@ func reconstructAliasedMap(node *CandidateNode, context Context) error { } } } - } else { + } else if showMergeAnchorToSpecWarning { log.Warning("--yaml-fix-merge-anchor-to-spec is false; causing merge anchors to override the existing values which isn't to the yaml spec. This flag will default to true in late 2025.") + showMergeAnchorToSpecWarning = false } for index := 0; index < len(node.Content); index = index + 2 { diff --git a/pkg/yqlib/operator_traverse_path.go b/pkg/yqlib/operator_traverse_path.go index 85490fff..2042828b 100644 --- a/pkg/yqlib/operator_traverse_path.go +++ b/pkg/yqlib/operator_traverse_path.go @@ -283,8 +283,6 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, node *CandidateNode, wante } } } - } else { - log.Warning("--yaml-fix-merge-anchor-to-spec is false; causing merge anchors to override the existing values which isn't to the yaml spec. This flag will default to true in late 2025.") } } @@ -296,6 +294,10 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, node *CandidateNode, wante if key.Tag == "!!merge" && !prefs.DontFollowAlias && wantedKey != key.Value { if !ConfiguredYamlPreferences.FixMergeAnchorToSpec { log.Debug("Merge anchor") + if showMergeAnchorToSpecWarning { + log.Warning("--yaml-fix-merge-anchor-to-spec is false; causing merge anchors to override the existing values which isn't to the yaml spec. This flag will default to true in late 2025.") + showMergeAnchorToSpecWarning = false + } err := traverseMergeAnchor(newMatches, value, wantedKey, prefs, splat) if err != nil { return err