func PatchResponseFromRaw(original, current []byte) Response {
	patches, err := jsonpatch.CreatePatch(original, current)
	if err != nil {
		return Errored(http.StatusInternalServerError, err)
	}
	return Response{
		Patches: patches,
		AdmissionResponse: admissionv1beta1.AdmissionResponse{
			Allowed:   true,
			PatchType: func() *admissionv1beta1.PatchType { pt := admissionv1beta1.PatchTypeJSONPatch; return &pt }(),
		},
	}
}
PatchResponseFromRaw takes 2 byte arrays and returns a new response with json patch.
The original object should be passed in as raw bytes to avoid the roundtripping problem
described in https://github.com/kubernetes-sigs/kubebuilder/issues/510.
package admission
import (
	"net/http"
	"gomodules.xyz/jsonpatch/v2"
	admissionv1beta1 "k8s.io/api/admission/v1beta1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func Allowed(reason string) Response {
	return ValidationResponse(true, reason)
}
func Denied(reason string) Response {
	return ValidationResponse(false, reason)
}
func Patched(reason string, patches ...jsonpatch.JsonPatchOperation) Response {
	resp := Allowed(reason)
	resp.Patches = patches
	return resp
}
func Errored(code int32, err error) Response {
	return Response{
		AdmissionResponse: admissionv1beta1.AdmissionResponse{
			Allowed: false,
			Result: &metav1.Status{
				Code:    code,
				Message: err.Error(),
			},
		},
	}
}
func ValidationResponse(allowed bool, reason string) Response {
	code := http.StatusForbidden
	if allowed {
		code = http.StatusOK
	}
	resp := Response{
		AdmissionResponse: admissionv1beta1.AdmissionResponse{
			Allowed: allowed,
			Result: &metav1.Status{
				Code: int32(code),
			},
		},
	}
	if len(reason) > 0 {
		resp.Result.Reason = metav1.StatusReason(reason)
	}
	return resp
}