Skip to content

Commit

Permalink
Describe diffs between our label-selector parser and upstream's.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpromislow committed Jan 14, 2025
1 parent c3a8df4 commit 607d208
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions pkg/stores/sqlpartition/queryparser/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@ This file is derived from
https://github.com/kubernetes/apimachinery/blob/master/pkg/labels/selector.go
*/

/**
Main changes:
1. The upstream `selector.go` file does parsing and applying to the objects being test.
We only care about the parser, so the selection part is dropped.
2. I dropped label value validation in the parser
3. Multiple values are returned as an array rather than a `k8s.io/utils/sets.String` object
to avoid having to pull in that dependency as well (and it isn't needed because we convert
the array into a sql statement. So the set gives us no benefit apart from removing duplicate target values).
4. We added the `QuotedStringToken` constant to distinguish exact matches from substring matches.
This needed the `SingleQuoteToken` and `DoubleQuoteToken` variants for the lexer.
5. Our filter language ignores case for `in` and `notin`. These must be lower-case in kubectl filter expressions.
6. The `Lexer.Lex` function names the return parameters in its header but has no argument-less
return statement, so I dropped the names.
7. We allow `lt` and `gt` as aliases for `<` and `>`.
*/

package queryparser

import (
Expand Down
4 changes: 2 additions & 2 deletions pkg/stores/sqlproxy/proxy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const (
)

var (
paramScheme = runtime.NewScheme()
paramCodec = runtime.NewParameterCodec(paramScheme)
paramScheme = runtime.NewScheme()
paramCodec = runtime.NewParameterCodec(paramScheme)
// Please keep the gvkKey entries in alphabetical order, on a field-by-field basis
typeSpecificIndexedFields = map[string][][]string{
gvkKey("", "v1", "ConfigMap"): {
Expand Down

0 comments on commit 607d208

Please sign in to comment.