@@ -77,7 +77,7 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
77
77
78
78
psc , generatedAnnotations , err := provider .CreatePodSecurityContext (pod )
79
79
if err != nil {
80
- errs = append (errs , field .Invalid (field . NewPath ("spec" , "securityContext" ), pod .Spec .SecurityContext , err .Error ()))
80
+ errs = append (errs , field .Invalid (fldPath . Child ("spec" , "securityContext" ), pod .Spec .SecurityContext , err .Error ()))
81
81
}
82
82
83
83
// save the original PSC and validate the generated PSC. Leave the generated PSC
@@ -88,11 +88,11 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
88
88
89
89
pod .Spec .SecurityContext = psc
90
90
pod .Annotations = generatedAnnotations
91
- errs = append (errs , provider .ValidatePodSecurityContext (pod , field . NewPath ("spec" , "securityContext" ))... )
91
+ errs = append (errs , provider .ValidatePodSecurityContext (pod , fldPath . Child ("spec" , "securityContext" ))... )
92
92
93
93
// Note: this is not changing the original container, we will set container SCs later so long
94
94
// as all containers validated under the same SCC.
95
- containerPath := field . NewPath ("spec" , "initContainers" )
95
+ containerPath := fldPath . Child ("spec" , "initContainers" )
96
96
for i , containerCopy := range pod .Spec .InitContainers {
97
97
csc , resolutionErrs := resolveContainerSecurityContext (provider , pod , & containerCopy , containerPath .Index (i ))
98
98
errs = append (errs , resolutionErrs ... )
@@ -106,7 +106,7 @@ func AssignSecurityContext(provider kscc.SecurityContextConstraintsProvider, pod
106
106
107
107
// Note: this is not changing the original container, we will set container SCs later so long
108
108
// as all containers validated under the same SCC.
109
- containerPath = field . NewPath ("spec" , "containers" )
109
+ containerPath = fldPath . Child ("spec" , "containers" )
110
110
for i , containerCopy := range pod .Spec .Containers {
111
111
csc , resolutionErrs := resolveContainerSecurityContext (provider , pod , & containerCopy , containerPath .Index (i ))
112
112
errs = append (errs , resolutionErrs ... )
0 commit comments