Files
cc4fb45d70 feat: upstream enterprise preview (#1841)
feat: upstream enterprise preview

---------

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
Co-authored-by: CorentinPtrl <pitrel.corentin@gmail.com>
2026-05-28 00:58:58 +02:00

30 lines
658 B
Go

// Copyright 2020-2026 Project Capsule Authors
// SPDX-License-Identifier: Apache-2.0
package admission
import (
"gomodules.xyz/jsonpatch/v2"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)
func AccumulateAdmissionResponse(
accumulated []jsonpatch.JsonPatchOperation,
response *admission.Response,
) ([]jsonpatch.JsonPatchOperation, *admission.Response) {
if response == nil {
return accumulated, nil
}
// Denied or errored responses must stop immediately.
if !response.Allowed {
return accumulated, response
}
if len(response.Patches) > 0 {
accumulated = append(accumulated, response.Patches...)
}
return accumulated, nil
}