Fix error check

Signed-off-by: Kevin Conner <kev.conner@gmail.com>
This commit is contained in:
Kevin Conner 2024-10-21 08:09:55 -07:00
parent 62bdf5d87c
commit e7e1fb7234

View File

@ -161,6 +161,11 @@ func (d *dispatcher) dispatchInvocations(
}
invocationKey, invocationKeyErr := keyFor(invocation)
if invocationKeyErr != nil {
// This should never happen. It occurs if there is a programming
// error causing the Param not to be a valid object.
return nil, k8serrors.NewInternalError(invocationKeyErr)
}
if reinvokeCtx.IsReinvoke() && !policyReinvokeCtx.ShouldReinvoke(invocationKey) {
continue
}
@ -169,12 +174,6 @@ func (d *dispatcher) dispatchInvocations(
// Mutations for a single invocation of a MutatingAdmissionPolicy are evaluated
// in order.
for mutationIndex := range invocation.Policy.Spec.Mutations {
if invocationKeyErr != nil {
// This should never happen. It occurs if there is a programming
// error causing the Param not to be a valid object.
return nil, k8serrors.NewInternalError(invocationKeyErr)
}
lastVersionedAttr = versionedAttr
if versionedAttr.VersionedObject == nil { // Do not call patchers if there is no object to patch.
continue