-
Notifications
You must be signed in to change notification settings - Fork 54
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
cleanups and refactor of protosanitizer #184
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: huww98 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @huww98! |
Hi @huww98. Thanks for your PR. I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
819e5e4
to
278086b
Compare
/ok-to-test |
It now works with all kinds of nested fields, and don't require json.Marshal() twice. The output also looks better for oneof and enum.
@jsafrane Can you also take a look at this one? It should speedup several times for cases like kubernetes-csi/external-provisioner#1310 when the log level is high. |
} | ||
} | ||
|
||
func stripValue(field protoreflect.FieldDescriptor, v protoreflect.Value) any { |
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.
Can be stripValue()
and stripSingleValue()
combined into a single function with a bigger switch?
switch {
case field.IsList():
...
case field.IsMap():
...
case field.Kind() == protoreflect.MessageKind:
...
case field.Kind() == ...
default: return v.Interface()
for i := range l.Len() { | ||
res[i] = stripSingleValue(field, l.Get(i)) |
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.
For example, what happens when a list has a list? Will it call stripSingleValue()
with a list, which then leads to default:
branch there and thus print the list with potential secrets?
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR does a series cleanups and refactors about protosanitizer:
About the output change of protosanitizer:
oneof
is reduced by one.Example diff of the output (manually formatted for diff):
Also added a benchmark to justify the new implementation:
Old:
New:
The new implementation is significantly faster, and allocates less memory
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
protosanitizer now imports csi spec directly, instead of copy over the
e_CsiSecret
. Since this module already requires the csi spec module, this should not break anyone.Support for CSI spec v0.3 is dropped, since the
csi.pb.go
file in that version does not implement the new protoreflect interface. And again, since this module already requires the csi spec module v1, users cannot use this module with v0.3 even without this PR. So, this is not a new breakage.Does this PR introduce a user-facing change?: