MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / mergeContainerSecurityContext

Function mergeContainerSecurityContext

pkg/config/sync.go:552–574  ·  view source on GitHub ↗
(base, patch *corev1.SecurityContext)

Source from the content-addressed store, hash-verified

550}
551
552func mergeContainerSecurityContext(base, patch *corev1.SecurityContext) *corev1.SecurityContext {
553 baseBytes, err := json.Marshal(base)
554 if err != nil {
555 log.Info("Failed to serialize base container security context: %s", err)
556 return base
557 }
558 patchBytes, err := json.Marshal(patch)
559 if err != nil {
560 log.Info("Failed to serialize configured container security context: %s", err)
561 return base
562 }
563 patchedBytes, err := strategicpatch.StrategicMergePatch(baseBytes, patchBytes, &corev1.SecurityContext{})
564 if err != nil {
565 log.Info("Failed to merge configured container security context: %s", err)
566 return base
567 }
568 patched := &corev1.SecurityContext{}
569 if err := json.Unmarshal(patchedBytes, patched); err != nil {
570 log.Info("Failed to deserialize patched container security context: %s", patched)
571 return base
572 }
573 return patched
574}
575
576func mergeTLSCertificateConfigmapRef(operatorConfig, clusterConfig *controller.ConfigmapReference) *controller.ConfigmapReference {
577 if clusterConfig == nil {

Callers 1

mergeConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected