mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +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
|
@ -4,6 +4,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/nirmata/kyverno/pkg/engine/context"
|
"github.com/nirmata/kyverno/pkg/engine/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ func ValidateVariables(ctx context.EvalInterface, pattern interface{}) string {
|
||||||
variableList := extractVariables(pattern)
|
variableList := extractVariables(pattern)
|
||||||
for i := 0; i < len(variableList)-1; i = i + 2 {
|
for i := 0; i < len(variableList)-1; i = i + 2 {
|
||||||
p := variableList[i+1]
|
p := variableList[i+1]
|
||||||
|
glog.V(3).Infof("validating variables %s", p)
|
||||||
val, err := ctx.Query(p)
|
val, err := ctx.Query(p)
|
||||||
// reference path is not present
|
// reference path is not present
|
||||||
if err == nil && val == nil {
|
if err == nil && val == nil {
|
||||||
|
|
|
@ -41,6 +41,7 @@ func (ws *WebhookServer) HandleGenerate(request *v1beta1.AdmissionRequest, polic
|
||||||
policyContext := engine.PolicyContext{
|
policyContext := engine.PolicyContext{
|
||||||
NewResource: *resource,
|
NewResource: *resource,
|
||||||
AdmissionInfo: userRequestInfo,
|
AdmissionInfo: userRequestInfo,
|
||||||
|
Context: ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
// engine.Generate returns a list of rules that are applicable on this resource
|
// 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{
|
policyContext := engine.PolicyContext{
|
||||||
NewResource: resource,
|
NewResource: resource,
|
||||||
AdmissionInfo: userRequestInfo,
|
AdmissionInfo: userRequestInfo,
|
||||||
|
Context: ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, policy := range policies {
|
for _, policy := range policies {
|
||||||
|
|
Loading…
Add table
Reference in a new issue