-
Notifications
You must be signed in to change notification settings - Fork 247
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
🌱 Clean up logging and error handling in the webhooks #1427
Conversation
df29012
to
e90a1f8
Compare
/test-centos-e2e-integration-main |
1 similar comment
/test-centos-e2e-integration-main |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: zaneb 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 |
var errs []error | ||
|
||
if s.Spec.HostName == "" { | ||
errs = append(errs, fmt.Errorf("HostName cannot be empty")) | ||
errs = append(errs, errors.New("hostName cannot be empty")) |
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.
We should be validating this client-side, you don't need a webhook just to make sure a field is not empty.
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 agree, but I'd rather keep this PR refactoring-only
e90a1f8
to
10b8065
Compare
Logging: - Rename the webhook loggers for consistency and easier grepping - Remove redundant logging from the validation code Errors: - Provide wrapped errors in a consistent fashion - Do not refer to internal constant names in user-visible strings - Match field names to those in JSON (i.e. camelCase) - Provide allowed values when saying that something is not allowed - Use the stdlib error routines instead of the deprecated pkg/errors. - Do not shadow the errors package name by local variables
10b8065
to
a72ffa6
Compare
/test-centos-e2e-integration-main |
/lgtm |
metal3-io/baremetal-operator#1427 switches both webhooks to use the name 'webhooks' for the logger.
Logging:
Errors: