Replace panic with error return in Policy()#52
Conversation
7737b0e to
7552ff5
Compare
Policy() previously called panic() on YAML parse failures or invalid regex patterns in policy rules. Return an error instead so callers can handle it gracefully rather than crashing the process.
7552ff5 to
0a27370
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sebrandon1, smith-xyz The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm note on the jobs: we're adjusting ci to only run a smoke tests for PRs for faster iteration |
|
Sounds good! Thanks @smith-xyz |
|
/test images |
|
@sebrandon1: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
|
Closing in favor of #60 which now includes this change (Policy() returns error instead of panicking) alongside the slog logging migration. |
Summary
Policy()from*ComponentPolicyto(*ComponentPolicy, error)so callers can handle parse failures gracefully instead of crashingmain.goto log the error and exit with code 1testPolicy(t)test helper that callst.Fatalon errorTest plan
go build ./...passesgo test ./...passesgo vet ./...passes