func mutate(rawPod []byte, ns string, m mutateFunc, dc dynamic.Interface) ([]byte, error) {
	var pod corev1.Pod
	if err := json.Unmarshal(rawPod, &pod); err != nil {
		return nil, fmt.Errorf("failed to decode raw object: %v", err)
	}

	if err := m(&pod, ns, dc); err != nil {
		return nil, err
	}

	bytes, err := json.Marshal(pod)
	if err != nil {
		return nil, fmt.Errorf("failed to encode the mutated Pod object: %v", err)
	}

	patchOperation, err := jsonpatch.CreatePatch(rawPod, bytes) // TODO: Try to generate the patch at the mutateFunc
	if err != nil {
		return nil, fmt.Errorf("failed to prepare the JSON patch: %v", err)
	}

	return json.Marshal(patchOperation)
}
// mutate handles mutating pods and encoding and decoding admission
// requests and responses for the public mutate functions
mutate handles mutating pods and encoding and decoding admission
requests and responses for the public mutate functions
// mutate handles mutating pods and encoding and decoding admission // requests and responses for the public mutate functions
func mutate(rawPod []byte, ns string, m mutateFunc, dc dynamic.Interface) ([]byte, error) {
	var pod corev1.Pod
	if err := json.Unmarshal(rawPod, &pod); err != nil {
		return nil, fmt.Errorf("failed to decode raw object: %v", err)
	}
	if err := m(&pod, ns, dc); err != nil {
		return nil, err
	}
	bytes, err := json.Marshal(pod)
	if err != nil {
		return nil, fmt.Errorf("failed to encode the mutated Pod object: %v", err)
	}
	patchOperation, err := jsonpatch.CreatePatch(rawPod, bytes) 
	if err != nil {
		return nil, fmt.Errorf("failed to prepare the JSON patch: %v", err)
	}
	return json.Marshal(patchOperation)
}
func mutate ( rawPod [ ] byte , ns string , m mutateFunc , dc dynamic . Interface ) ( [ ] byte , error ) { var pod corev1 . Pod if err := json . Unmarshal ( rawPod , & pod ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := m ( & pod , ns , dc ) ; err != nil { return nil , err } bytes , err := json . Marshal ( pod ) if err != nil { return nil , fmt . Errorf ( " " , err ) } patchOperation , err := jsonpatch . CreatePatch ( rawPod , bytes ) if err != nil { return nil , fmt . Errorf ( " " , err ) } return json . Marshal ( patchOperation ) }
mutate handles mutating pods and encoding and decoding admission
requests and responses for the public mutate functions
mutate handles mutating pods and encoding and decoding admission requests and responses for the public mutate functions
// TODO: Try to generate the patch at the mutateFunc