mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 19:05:27 +00:00
pass in ctx to mutation and generation
This commit is contained in:
parent
4c83ab8b52
commit
f618bbcff3
3 changed files with 4 additions and 0 deletions
pkg
|
@ -4,6 +4,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/nirmata/kyverno/pkg/engine/context"
|
||||
)
|
||||
|
||||
|
@ -14,6 +15,7 @@ func ValidateVariables(ctx context.EvalInterface, pattern interface{}) string {
|
|||
variableList := extractVariables(pattern)
|
||||
for i := 0; i < len(variableList)-1; i = i + 2 {
|
||||
p := variableList[i+1]
|
||||
glog.V(3).Infof("validating variables %s", p)
|
||||
val, err := ctx.Query(p)
|
||||
// reference path is not present
|
||||
if err == nil && val == nil {
|
||||
|
|
|
@ -41,6 +41,7 @@ func (ws *WebhookServer) HandleGenerate(request *v1beta1.AdmissionRequest, polic
|
|||
policyContext := engine.PolicyContext{
|
||||
NewResource: *resource,
|
||||
AdmissionInfo: userRequestInfo,
|
||||
Context: ctx,
|
||||
}
|
||||
|
||||
// engine.Generate returns a list of rules that are applicable on this resource
|
||||
|
|
|
@ -71,6 +71,7 @@ func (ws *WebhookServer) HandleMutation(request *v1beta1.AdmissionRequest, resou
|
|||
policyContext := engine.PolicyContext{
|
||||
NewResource: resource,
|
||||
AdmissionInfo: userRequestInfo,
|
||||
Context: ctx,
|
||||
}
|
||||
|
||||
for _, policy := range policies {
|
||||
|
|
Loading…
Add table
Reference in a new issue