| 526 | } |
| 527 | |
| 528 | func mergePodSecurityContext(base, patch *corev1.PodSecurityContext) *corev1.PodSecurityContext { |
| 529 | baseBytes, err := json.Marshal(base) |
| 530 | if err != nil { |
| 531 | log.Info("Failed to serialize base pod security context: %s", err) |
| 532 | return base |
| 533 | } |
| 534 | patchBytes, err := json.Marshal(patch) |
| 535 | if err != nil { |
| 536 | log.Info("Failed to serialize configured pod security context: %s", err) |
| 537 | return base |
| 538 | } |
| 539 | patchedBytes, err := strategicpatch.StrategicMergePatch(baseBytes, patchBytes, &corev1.PodSecurityContext{}) |
| 540 | if err != nil { |
| 541 | log.Info("Failed to merge configured pod security context: %s", err) |
| 542 | return base |
| 543 | } |
| 544 | patched := &corev1.PodSecurityContext{} |
| 545 | if err := json.Unmarshal(patchedBytes, patched); err != nil { |
| 546 | log.Info("Failed to deserialize patched pod security context: %s", patched) |
| 547 | return base |
| 548 | } |
| 549 | return patched |
| 550 | } |
| 551 | |
| 552 | func mergeContainerSecurityContext(base, patch *corev1.SecurityContext) *corev1.SecurityContext { |
| 553 | baseBytes, err := json.Marshal(base) |