mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 16:06:56 +00:00
feat: add CEL variables support (#11913)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
34bc3994a3
commit
9177c57b21
1 changed files with 10 additions and 3 deletions
|
@ -14,7 +14,10 @@ import (
|
|||
|
||||
const (
|
||||
ContextKey = "context"
|
||||
NamespaceObjectKey = "namespaceObject"
|
||||
ObjectKey = "object"
|
||||
OldObjectKey = "oldObject"
|
||||
RequestKey = "request"
|
||||
VariablesKey = "variables"
|
||||
)
|
||||
|
||||
|
@ -37,8 +40,12 @@ func (c *compiler) Compile(policy *kyvernov2alpha1.ValidatingPolicy) (*CompiledP
|
|||
provider := NewVariablesProvider(base.CELTypeProvider())
|
||||
env, err := base.Extend(
|
||||
cel.Variable(ContextKey, context.ContextType),
|
||||
cel.Variable(NamespaceObjectKey, cel.DynType),
|
||||
cel.Variable(ObjectKey, cel.DynType),
|
||||
cel.Variable(OldObjectKey, cel.DynType),
|
||||
cel.Variable(RequestKey, cel.DynType),
|
||||
cel.Variable(VariablesKey, VariablesType),
|
||||
// TODO: params, authorizer, authorizer.requestResource ?
|
||||
cel.CustomTypeProvider(provider),
|
||||
)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue