diff --git a/pkg/reconciler/eventlistener/eventlistener_test.go b/pkg/reconciler/eventlistener/eventlistener_test.go index 8214f3115..651205e1d 100644 --- a/pkg/reconciler/eventlistener/eventlistener_test.go +++ b/pkg/reconciler/eventlistener/eventlistener_test.go @@ -917,10 +917,7 @@ func TestReconcile(t *testing.T) { deploymentMissingSecurityContext := makeDeployment(func(d *appsv1.Deployment) { d.Spec.Template.Spec.SecurityContext = &corev1.PodSecurityContext{} - d.Spec.Template.Spec.Containers[0].SecurityContext = &corev1.SecurityContext{ - RunAsUser: ptr.Int64(65532), - RunAsGroup: ptr.Int64(65532), - } + d.Spec.Template.Spec.Containers[0].SecurityContext = &corev1.SecurityContext{} }) deploymentWithSecurityContext := makeDeployment(func(d *appsv1.Deployment) { diff --git a/pkg/reconciler/eventlistener/resources/container.go b/pkg/reconciler/eventlistener/resources/container.go index 62db83b3b..07ae3c279 100644 --- a/pkg/reconciler/eventlistener/resources/container.go +++ b/pkg/reconciler/eventlistener/resources/container.go @@ -66,13 +66,12 @@ func MakeContainer(el *v1beta1.EventListener, configAcc reconcilersource.ConfigA if *c.SetReadOnlyRootFilesystem { containerSecurityContext.ReadOnlyRootFilesystem = ptr.Bool(true) } - } - - if !cfg.Defaults.IsDefaultRunAsUserEmpty { - containerSecurityContext.RunAsUser = ptr.Int64(cfg.Defaults.DefaultRunAsUser) - } - if !cfg.Defaults.IsDefaultRunAsGroupEmpty { - containerSecurityContext.RunAsGroup = ptr.Int64(cfg.Defaults.DefaultRunAsGroup) + if !cfg.Defaults.IsDefaultRunAsUserEmpty { + containerSecurityContext.RunAsUser = ptr.Int64(cfg.Defaults.DefaultRunAsUser) + } + if !cfg.Defaults.IsDefaultRunAsGroupEmpty { + containerSecurityContext.RunAsGroup = ptr.Int64(cfg.Defaults.DefaultRunAsGroup) + } } container := corev1.Container{