@@ -75,7 +75,7 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
75
75
76
76
psc , generatedAnnotations , err := provider .CreatePodSecurityContext (pod )
77
77
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 ()))
79
79
}
80
80
81
81
// save the original PSC and validate the generated PSC. Leave the generated PSC
@@ -86,11 +86,11 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
86
86
87
87
pod .Spec .SecurityContext = psc
88
88
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" ))... )
90
90
91
91
// Note: this is not changing the original container, we will set container SCs later so long
92
92
// as all containers validated under the same SCC.
93
- containerPath := field . NewPath ("spec" , "initContainers" )
93
+ containerPath := fldPath . Child ("spec" , "initContainers" )
94
94
for i , containerCopy := range pod .Spec .InitContainers {
95
95
csc , resolutionErrs := resolveContainerSecurityContext (provider , pod , & containerCopy , containerPath .Index (i ))
96
96
errs = append (errs , resolutionErrs ... )
@@ -104,7 +104,7 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
104
104
105
105
// Note: this is not changing the original container, we will set container SCs later so long
106
106
// as all containers validated under the same SCC.
107
- containerPath = field . NewPath ("spec" , "containers" )
107
+ containerPath = fldPath . Child ("spec" , "containers" )
108
108
for i , containerCopy := range pod .Spec .Containers {
109
109
csc , resolutionErrs := resolveContainerSecurityContext (provider , pod , & containerCopy , containerPath .Index (i ))
110
110
errs = append (errs , resolutionErrs ... )
0 commit comments