-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interaction between regular expressions and YAML path segments is unclear #266
Comments
I don't quite understand your question and what exactly do you mean by ambiguity, but Line 94 in 86654f8
(Path.String() returns the string with go-patch style separators) So in your example the correct regexp would be ^/metadata/.+/generation$
The exact behavior should probably be documented somewhere. Unless I'm missing something you literally can't use this feature correctly without perusing the source code |
Yep, that'll work; thanks for helping get me to that point. It should be good enough for my use, since I'm not expecting to run into any ambiguous paths.
Agreed. The ambiguity I was talking about is when you have a path which is collapsed into a string with some separator (dots, slashes, it doesn't matter; I spend more time with Here's a concrete example: metadata:
annotations:
prometheus.io/scrape: true
prometheus.io:
scrape: false (Ignoring the fact that this isn't a valid Kubernetes manifest.) Does dyff between --exclude-regexp 'annotations/prometheus.io/scrape' \
=(jq -n '.annotations["prometheus.io/scrape"] |= true | .annotations["prometheus.io"].scrape |= true') \
=(jq -n '.annotations["prometheus.io/scrape"] |= false | .annotations["prometheus.io"].scrape |= false') returns no differences. I think I would expect the expression to refer to the I had trouble figuring out what "go-patch" means, though. Google got me to RFC6902 (JSON Patch), which relies on RFC6901 (JSON Path), which uses It looks like |
This bug has morphed a bit. I had originally tried to do
--exclude-regexp metadata\.annotations\.checksum/.*
, mistakenly thinking that the dots were part of a string that needed to be escaped in order not to match too many strings, and not the separators between path segments.But that raises the question of how those two syntaxes interact. For instance, if I want to exclude any item whose path starts with
metadata
and ends withgeneration
, how do I express that? It seems thatmetadata.*generation
works, but possibly by accident? At least, I wouldn't know how to filterdistinctly from
or
There are a similar set of ambiguous patterns using
/
as the separator, too.In tracking this down, I noticed that the tests are also missing examples which contain regular expression metacharacters (not that they would have caught this particular problem).
Ambiguity is probably fine 99% of the time, but even having that much documented would be really handy. Unfortunately, that seems like it's getting into manpage territory ....
I'll note with a crazy look in my eye that
helm
uses (AFAIK completely undocumented) vertical tab (\v
) as a separator internally, so if you have, say, adatadog
repo configured, which hasdatadog
,datadog-crds
, anddatadog-operator
charts, you can search for\vdatadog/datadog\v
to find just the first. Perhaps it might make sense to treat\v
as a segment separator here, too, assuming it's not possible to use that character in a YAML key.The text was updated successfully, but these errors were encountered: