mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 10:55:05 +00:00
522 added service account name in context
This commit is contained in:
parent
044d55600a
commit
b27a62b6bf
1 changed files with 9 additions and 2 deletions
|
@ -79,10 +79,17 @@ func ValidatePolicyMutation(policy v1.ClusterPolicy) error {
|
|||
resource, _ := generateEmptyResource(openApiGlobalState.definitions[openApiGlobalState.kindToDefinitionName[kind]]).(map[string]interface{})
|
||||
newResource := unstructured.Unstructured{Object: resource}
|
||||
newResource.SetKind(kind)
|
||||
|
||||
ctx := context.NewContext()
|
||||
err := ctx.AddSA("kyvernoDummyUsername")
|
||||
if err != nil {
|
||||
glog.Infof("Failed to load service account in context:%v", err)
|
||||
}
|
||||
|
||||
policyContext := engine.PolicyContext{
|
||||
Policy: newPolicy,
|
||||
NewResource: newResource,
|
||||
Context: context.NewContext(),
|
||||
Context: ctx,
|
||||
}
|
||||
resp := engine.Mutate(policyContext)
|
||||
if len(resp.GetSuccessRules()) != len(rules) {
|
||||
|
@ -94,7 +101,7 @@ func ValidatePolicyMutation(policy v1.ClusterPolicy) error {
|
|||
}
|
||||
return fmt.Errorf(strings.Join(errMessages, "\n"))
|
||||
}
|
||||
err := ValidateResource(resp.PatchedResource.UnstructuredContent(), kind)
|
||||
err = ValidateResource(resp.PatchedResource.UnstructuredContent(), kind)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue