karmada
karmada copied to clipboard
operator/pkg: mitigate null pointer dereference in `Validate()` and `newRunData()` functions
Description
In this commit, we mitigate the null pointer dereference issue in the deinit operator pkg by adding defensive checks on
opt.Karmada.Spec.HostCluster
in newRunData
func and on opt.Karmada.Spec.Components
in Validate
in init.go
.
Motivation and Context
While unit testing the Karmada Init and DeInit in the operator package (#5613), deliberately passing empty components on those fields triggers a null pointer exception error. This PR resolves this issue by adding defensive checks.
While testing
What type of PR is this?
/kind cleanup
Does this PR introduce a user-facing change?:
NONE