Skip to content

Commit 0b87377

Browse files
committed
Show SCC provider in error message.
1 parent 846289d commit 0b87377

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/security/scc/matcher.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
7575

7676
psc, generatedAnnotations, err := provider.CreatePodSecurityContext(pod)
7777
if err != nil {
78-
errs = append(errs, field.Invalid(field.NewPath("spec", "securityContext"), pod.Spec.SecurityContext, err.Error()))
78+
errs = append(errs, field.Invalid(fldPath.Child("spec", "securityContext"), pod.Spec.SecurityContext, err.Error()))
7979
}
8080

8181
// save the original PSC and validate the generated PSC. Leave the generated PSC
@@ -86,11 +86,11 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
8686

8787
pod.Spec.SecurityContext = psc
8888
pod.Annotations = generatedAnnotations
89-
errs = append(errs, provider.ValidatePodSecurityContext(pod, field.NewPath("spec", "securityContext"))...)
89+
errs = append(errs, provider.ValidatePodSecurityContext(pod, fldPath.Child("spec", "securityContext"))...)
9090

9191
// Note: this is not changing the original container, we will set container SCs later so long
9292
// as all containers validated under the same SCC.
93-
containerPath := field.NewPath("spec", "initContainers")
93+
containerPath := fldPath.Child("spec", "initContainers")
9494
for i, containerCopy := range pod.Spec.InitContainers {
9595
csc, resolutionErrs := resolveContainerSecurityContext(provider, pod, &containerCopy, containerPath.Index(i))
9696
errs = append(errs, resolutionErrs...)
@@ -104,7 +104,7 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
104104

105105
// Note: this is not changing the original container, we will set container SCs later so long
106106
// as all containers validated under the same SCC.
107-
containerPath = field.NewPath("spec", "containers")
107+
containerPath = fldPath.Child("spec", "containers")
108108
for i, containerCopy := range pod.Spec.Containers {
109109
csc, resolutionErrs := resolveContainerSecurityContext(provider, pod, &containerCopy, containerPath.Index(i))
110110
errs = append(errs, resolutionErrs...)

0 commit comments

Comments
 (0)