-
Notifications
You must be signed in to change notification settings - Fork 4
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
events: replace string literals with variables #23
events: replace string literals with variables #23
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: clobrano The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Following this discussion, this change can be useful when an operator has un-common events that fall into the same category of other "common" events already available as API (e.g. |
pkg/events/events.go
Outdated
} | ||
|
||
// GetTargetNodeFailed will record a Warning event with reason RemediationFailed and message "Could not get remediation target node". | ||
func GetTargetNodeFailed(recorder record.EventRecorder, object runtime.Object) { | ||
WarningEvent(recorder, object, "RemediationCannotStart", "Could not get remediation target Node") | ||
WarningEvent(recorder, object, RemediationCannotStartEventReason, RemediationCannotStartEventMessage) |
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 is very inconsistent :/
func name: GetTargetNodeFailed
reason: RemediationCannotStart
message: var name RemediationCannotStart, but value about the target node
IMHO most useful would be:
func name: RemediationCannotStart
reason: RemediationCannotStart
msg: passed in by parameter, there probably can be multiple reasons for a remediation to not start
Changing this would be an API change though, which would, when done correctly, need a major version bump...
So my suggestion is:
- rename the msg var to e.g. RemediationCannotStartTargetNodeFailedEventMessage , to make its meaning a bit clearer
- add a function as suggested above, and use it inside GetTargetNodeFailed?
WDYT?
Also, while I agree that the reasons should be consistent and might be worth adding to the API, I don't see that for the messages. What's the motivation for making them public?
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.
What's the motivation for making them public?
Mostly testing, but I'm still torn about leaving this information available only for testing and I won't mind reverting this particular bit 🤷
this is very inconsistent :/
I agree. I dunno why I choose a function name so different than the others :/
rename the msg var to e.g. RemediationCannotStartTargetNodeFailedEventMessage , to make its meaning a bit clearer
etc.
sounds like a good idea :)
Add variables for event reasons and messages to allow reuse of the same messages and help tests. Signed-off-by: Carlo Lobrano <[email protected]>
4d4d6fc
to
8a66302
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.
This is better now, lgtm
Going to leave it open for others to review who use this more than I do :)
dismissing a review for getting rid of requesting changes, does it work? 🤷
/lgtm |
those functions still have a fixed message. Only |
Correct, and I was referring to the other functions :) |
Yes, thank you, now I understand it better and it makes sense |
Signed-off-by: Carlo Lobrano <[email protected]>
/lgtm |
Add variables for event reasons and messages to allow reuse of the same
messages and help tests.
Signed-off-by: Carlo Lobrano [email protected]