-
Notifications
You must be signed in to change notification settings - Fork 405
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
Fix handling of 'has' selectors #473
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes to reviewers.
if kind == "" { | ||
return false, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only case where docKind()
returns an empty kind
string without error is when the node is a !!null
node.
I'm not sure under what circumstances such node is passed to MatchesSelector()
, but I had to short-circuit here because objMatchesSelector()
doesn't understand what a !!null
node is.
I'm happy to remove this check on kind
and add a check for !!null
to objMatchesSelector()
instead, in case someone feels strongly about it.
}, { | ||
desc: "null node", | ||
input: "!!null", | ||
selector: labels.Everything(), | ||
matches: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment for the reason for this removal.
Thanks for adding this! This looks fine to me, @jonjohnsonjr do you have any comments? |
I'm not enough of a yaml engineer to have a strong opinion about this, lgtm if you think it's fine. |
Fixes #467
The first commit includes test cases which surface the issue.
The second one includes a fix, which consists in treating a missing
metadata.labels
as a{}
map.Test run before fix: