-
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
return obj, nil | ||
} | ||
|
||
func addLabelFields(raw *unstructured.Unstructured) error { | ||
labels := raw.GetLabels() |
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.
This code never returns an error?
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.
True, good catch.
@@ -74,6 +100,15 @@ func addIDField(raw *unstructured.Unstructured) *unstructured.Unstructured { | |||
return raw | |||
} | |||
|
|||
// updateTypeField replaces the _type field with the contents of the field named "type", if it exists | |||
func fixTypeField(raw *unstructured.Unstructured) *unstructured.Unstructured { |
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.
It's not clear why this returns the resource, it's modified in place?
addLabelFields
also modifies in place, but doesn't return anything?
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.
This function is part of the transformFunc chain at https://github.com/ericpromislow/steve/blob/f8103ff621f792ea1e6a9399d087f170b1a54f8f/pkg/resources/virtual/virtual.go#L48
@@ -74,6 +100,15 @@ func addIDField(raw *unstructured.Unstructured) *unstructured.Unstructured { | |||
return raw | |||
} | |||
|
|||
// updateTypeField replaces the _type field with the contents of the field named "type", if it exists | |||
func fixTypeField(raw *unstructured.Unstructured) *unstructured.Unstructured { | |||
currentTypeValue, ok := raw.Object["type"] |
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.
This could dispense with the comma, ok approach and just get the value, and if it's not nil
, store it?
Presumably an empty string (or other value) shouldn't be used as the _type
?
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.
Turns out this function was replaced by TransformEventObject
, which returns a nil error because it's part of that same object-transform loop.
return obj, nil | ||
} | ||
|
||
// TransformLabels caches the labels |
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.
This comment sounds wrong?
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, and I see the code was calling TransformLabels
twice. The second call has no effect, but is confusing.
@@ -266,6 +266,36 @@ func TestParseQuery(t *testing.T) { | |||
return nil | |||
}, | |||
}) | |||
tests = append(tests, testCase{ | |||
description: "ParseQuery() with a labels filter param " + |
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 think you need to break this over two strings?
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. I'm still a slave to the 80-character guideline.
@@ -0,0 +1,143 @@ | |||
package queryparser |
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.
Should this not retain its original license header?
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.
good point. I made a few changes but let me look into it
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.
- Remove the erroneously added management.cattle.io.nodes fields - Use the builtin Event class, not events.k8s.io (by looking at the dashboard client code)
Following clause 4.3 of the Apache license: "You must cause any modified files to carry prominent notices stating that You changed the files..."
SQL is case-insensitive on field names and values, so this just adds consistency.
548c4c2
to
1368056
Compare
Related to #46333
Works with lasso PR rancher/lasso#117
Marked as draft because
go.mod
has areplace lasso ... ../lasso
directive.