-
Notifications
You must be signed in to change notification settings - Fork 80
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
Index arbitrary labels #317
base: main
Are you sure you want to change the base?
Index arbitrary labels #317
Conversation
697fdee
to
3bbfa55
Compare
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.
Mostly fine, I would much prefer to see some real tests against SQLite rather than the continued use of mocks.
3bbfa55
to
cfdeafd
Compare
"I would much prefer to see some real tests against SQLite rather than the continued use of mocks." This is covered in tech-debt item |
607d208
to
3ea8184
Compare
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.
Thanks @ericpromislow, I do not see big issues either. Most comments from my part are really suggestions and should be quick to address.
Ready to approve as soon as they are dealt with.
👀 from @tomleb would also be helpful
return false | ||
} | ||
s1 := values[0][0:1] | ||
if !strings.Contains(`"'`, s1) { |
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.
When filtering for exact matches, do we want the string to be single quoted, double quoted, or support both? I am asking because the current behavior seem to be single quote:
and IIUC this change would make it either single or double quote. Alas, we never documented the choice on the README.
@richard-cox do you have a preference?
@ericpromislow can you amend the README so that whatever we decide is documented please?
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.
Currently
'
denotes exact match- no quotes denotes partial match
From my interpretation of docs the proposal would be the following?
'
denotes exact match"
denotes partial match- no quotes syntax has been removed?
I think ideally we would continue as currently. all other params, include those that contain text, do not require "
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.
No, quotes are still optional. And I've implemented single quotes indicate an exact match, and double quotes don't (they're just used to delimit the contents, but because of the syntax of k8s labels, they're never required because characters like spaces aren't allowed).
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.
Do we need double quotes at all?
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.
My first thought was it should probably be the operator that decides if its an exact match equality or a substring match. Something like: =
is exact (stay closer to k8s), =~
is substring. !~
is not equal substring.
Imo we should have only one way per matching strategy, I don't see a reason to have both double quotes and no quotes denote substring match. That should simplify the logic a bit too.
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.
ok, double quotes are gone and trigger a syntax error
87eea56
to
7dd7067
Compare
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.
Looks good from my perspective.
We definitely need:
-
@richard-cox's perspective on https://github.com/rancher/steve/pull/317/files?w=0#r1918171835 / https://github.com/rancher/steve/pull/317/files?w=0#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R120-R136
-
another look from somebody in Frameworks (@tomleb ?) especially from a maintenance perspective
4075bc5
to
3f6a70a
Compare
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.
Mostly nits / styling, one question about the deepcopy, but overall LGTM
@@ -0,0 +1,48 @@ | |||
//go:build !ignore_autogenerated |
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.
WDYT stripping this out as well? We're unlikely to be able to regenerate it if we make changes to Requirements
. Do we need it to be deepcopy?
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.
I don't have any opinion on this. All this code came as-is from kubectl.
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.
So imo if we don't have anything to regenerate the file we shouldn't add the autogenerated file ourselves if we don't need it. In this case I don't think we need the deepcopy code (I might be wrong, you'll have to try to remove it see if things still compile), so I'd suggest just removing it.
SingleQuoteToken | ||
DoubleQuoteToken |
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.
I'm not sure those are necessary as they aren't used anywhere. For example, the tests passed even with them removed.
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.
Yes, dropped in an earlier commit
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.
But I still see them so it looks like they were brought back? Unless I misunderstand. (eg: I'm fairly sure we can remove both SingleQuoteToken
and DoubleQuoteToken
here.
"'": SingleQuoteToken, | ||
"\"": DoubleQuoteToken, |
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.
I'm not sure those are necessary as they aren't used anywhere. For example, the tests passed even with them removed.
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.
Yup, dropped
return false | ||
} | ||
s1 := values[0][0:1] | ||
if !strings.Contains(`"'`, s1) { |
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.
My first thought was it should probably be the operator that decides if its an exact match equality or a substring match. Something like: =
is exact (stay closer to k8s), =~
is substring. !~
is not equal substring.
Imo we should have only one way per matching strategy, I don't see a reason to have both double quotes and no quotes denote substring match. That should simplify the logic a bit too.
The UI team wasn't sure whether the event fields should go in the empty-string group or in 'events.k8s.io', so let's go with both until/unless specified otherwise.
I see both types of operators being bandied about -- it's easy to support the aliases.
Also reduce the case where there's no namespace function.
- Stricter processing of m.l.name keys: Require ending close-bracket for a start-bracket - Comment fix - Moving sql processing from lasso to steve: some changes missed in rebase
For now on only single-quotes (or none where possible) are allowed.
The requirements come form the dashboard, and they're the main consumer of this. So they'll need to weigh in on these operators. But I added the double-quotes as a sort of symmetric thing and they're easily dropped. |
3f6a70a
to
67a44aa
Compare
From an architectural perspective “defaulting to Kubernetes standards and extending them when needed” seems like the most sensible thing to do, but I’ll leave the final decision to the UI team (cc @richard-cox). |
string(selection.GreaterThan), string(selection.LessThan), | ||
} | ||
validRequirementOperators = append(binaryOperators, unaryOperators...) | ||
labelSelectorRegex = regexp.MustCompile(`^metadata.labels(?:\.\w[-a-zA-Z0-9_./]*|\[.*])$`) |
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.
Per previous discussion:
labelSelectorRegex = regexp.MustCompile(`^metadata.labels(?:\.\w[-a-zA-Z0-9_./]*|\[.*])$`) | |
labelSelectorRegex = regexp.MustCompile(`^metadata\.labels((\.\w[-a-zA-Z0-9_./]*)|(\[.*\]))$`) |
- quotes the first literal dot
- separates the "dot + identifier" case from the "square brackets with anything inside" case in two parenthesized groups for readability
- quotes the
]
for readability
https://go.dev/play/p/ybN1HHir7oY
Does that make sense?
Dashboard side as long as we can execute equals or not equals operators and exact or partial matching of the value we're pretty free on the syntax. Implementation side the usage is abstracted away from the api syntax, so it's an easy update either way Changing the operator will make the type of match much more obvious. I had some minor concerns with tilde (this used to be a reserved character relating to the home directory and used when locating assets), though looks fine now https://datatracker.ietf.org/doc/html/rfc3986#section-2.3 For url brevity i would go with the following
|
Related to #46333