-
Notifications
You must be signed in to change notification settings - Fork 62
✨ Reformat error wrapping for resolved bundle status #1938
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
errMissingRBAC = "pre-authorization failed: service account requires the following permissions to manage cluster extension:\n" + | ||
" Namespace:\"\" APIGroups:[] Resources:[services] Verbs:[list,watch]\n" + | ||
" Namespace:\"test-namespace\" APIGroups:[*] Resources:[certificates] Verbs:[create]\n" |
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 would suggest using backticks to format multi-line strings and/or strings containing quotation marks:
errMissingRBAC = "pre-authorization failed: service account requires the following permissions to manage cluster extension:\n" + | |
" Namespace:\"\" APIGroups:[] Resources:[services] Verbs:[list,watch]\n" + | |
" Namespace:\"test-namespace\" APIGroups:[*] Resources:[certificates] Verbs:[create]\n" | |
errMissingRBAC = `pre-authorization failed: service account requires the following permissions to manage cluster extension: | |
Namespace:"" APIGroups:[] Resources:[services] Verbs:[list,watch] | |
Namespace:"test-namespace" APIGroups:[*] Resources:[certificates] Verbs:[create] | |
` |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1938 +/- ##
==========================================
+ Coverage 65.87% 66.23% +0.35%
==========================================
Files 71 71
Lines 6189 6189
==========================================
+ Hits 4077 4099 +22
+ Misses 1850 1827 -23
- Partials 262 263 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
// End the error in a newline since this is a heavily formatted collection of errors such as missing RBAC rules | ||
// and we don't want it to run along into any following errors, i.e. the status error wrapping in clusterextension_controller |
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.
Is there an example of where this actually happens? If so, that's probably because we are not using errors.Join
in that location?
(i.e. if we used errors.Join all the way up the stack, we'd get newlines between all the errors, but no extraneous newlines otherwise)
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.
That will put our error message at the beginning of the string, and I could see how that could make formatting look strange. Maybe we should reformat that string so that the error still ends up at the end. Would that resolve the problem you are seeing with the lack of a trailing new line?
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.
Yep, that's the specific location where this is happening. If it's fine to rework this, then I'll do that instead and make it use Join().
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.
Yeah, let's do that instead. But in this case it isn't a different error. This is just adding some context to this error. I think we should try to just rewrite the wrapping such that it is <context>: <underlying error>
Adds another test case to helm_test.go for when PreAuthorize() returns missing RBAC rules. Merges the noOpPreauthorizer and errPreAuthorizer into one mockPreAuthorizer in helm_test.go. Reverses the structure of the error string in wrapErrorWithResolutionInfo such that the context is first and the error follows. Signed-off-by: Tayler Geiger <[email protected]>
Adds another test case to helm_test.go for when PreAuthorize() returns missing RBAC rules.
Description
Reviewer Checklist