Skip to content

Commit f35e57d

Browse files
committed
Warn less about flag
1 parent 70ac3d6 commit f35e57d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pkg/yqlib/operator_anchors_aliases.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"slices"
77
)
88

9+
var showMergeAnchorToSpecWarning = true
10+
911
func assignAliasOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
1012

1113
log.Debugf("AssignAlias operator!")
@@ -159,8 +161,9 @@ func reconstructAliasedMap(node *CandidateNode, context Context) error {
159161
}
160162
}
161163
}
162-
} else {
164+
} else if showMergeAnchorToSpecWarning {
163165
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.")
166+
showMergeAnchorToSpecWarning = false
164167
}
165168

166169
for index := 0; index < len(node.Content); index = index + 2 {

pkg/yqlib/operator_traverse_path.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, node *CandidateNode, wante
283283
}
284284
}
285285
}
286-
} else {
287-
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.")
288286
}
289287
}
290288

@@ -296,6 +294,10 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, node *CandidateNode, wante
296294
if key.Tag == "!!merge" && !prefs.DontFollowAlias && wantedKey != key.Value {
297295
if !ConfiguredYamlPreferences.FixMergeAnchorToSpec {
298296
log.Debug("Merge anchor")
297+
if showMergeAnchorToSpecWarning {
298+
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.")
299+
showMergeAnchorToSpecWarning = false
300+
}
299301
err := traverseMergeAnchor(newMatches, value, wantedKey, prefs, splat)
300302
if err != nil {
301303
return err

0 commit comments

Comments
 (0)