From 0c1c6712fa5d3b8e4f8d81f8e8f5faea97136438 Mon Sep 17 00:00:00 2001 From: Sam Stoelinga Date: Fri, 22 Jul 2022 06:53:06 -0700 Subject: [PATCH] Add TODOs for using 1st party libraries from k8s --- pspmutating.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pspmutating.go b/pspmutating.go index 65e81b2..639fadc 100644 --- a/pspmutating.go +++ b/pspmutating.go @@ -29,6 +29,7 @@ import ( ) func GetContainerSecurityContexts(podSpec v1.PodSpec) []*v1.SecurityContext { + // TODO reuse VisitContainers from k8s pkg/api/pod/util.go scs := make([]*v1.SecurityContext, 0) for _, c := range podSpec.Containers { scs = append(scs, c.SecurityContext) @@ -82,6 +83,7 @@ func IsPodBeingMutatedByPSP(pod *v1.Pod, clientset *kubernetes.Clientset) (mutat if owner.Kind == "Node" { return false, diff, fmt.Errorf("Pod with ownerReference of kind Node is not supported. OwnerReference of pod %v was %#v", pod.Name, owner) } + // TODO investigate if 1st party library can be used such as github.com/google/go-cmp or smth from k8s if diffNew := deep.Equal(GetContainerSecurityContexts(parentPod.Spec), GetContainerSecurityContexts(pod.Spec)); diffNew != nil { diff = append(diff, diffNew...) }