Skip to content

Commit 02c6ca0

Browse files
authored
add namespace name into the pod policy name (#17)
1 parent e6656d8 commit 02c6ca0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

advisor/processor/generate.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func (p *Processor) SetNamespace(ns string) {
5252

5353
// GeneratePSP generate Pod Security Policy
5454
func (p *Processor) GeneratePSP(cssList []types.ContainerSecuritySpec, pssList []types.PodSecuritySpec) *v1beta1.PodSecurityPolicy {
55+
var ns string
5556
// no PSP will be generated if no security spec is provided
5657
if len(cssList) == 0 && len(pssList) == 0 {
5758
return nil
@@ -79,7 +80,13 @@ func (p *Processor) GeneratePSP(cssList []types.ContainerSecuritySpec, pssList [
7980

8081
notAllowPrivilegeEscationCount := 0
8182

82-
psp.Name = fmt.Sprintf("%s-%s", "pod-security-policy", time.Now().Format("20060102150405"))
83+
ns = p.namespace
84+
85+
if ns == "" {
86+
ns = "all"
87+
}
88+
89+
psp.Name = fmt.Sprintf("%s-%s-%s", "pod-security-policy", ns, time.Now().Format("20060102150405"))
8390

8491
for _, sc := range pssList {
8592
psp.Spec.HostPID = psp.Spec.HostPID || sc.HostPID

0 commit comments

Comments
 (0)