mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-24 08:36:46 +00:00
* fix: image parse func and add chainsaw tests Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: linter Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> --------- Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
36 lines
748 B
Go
36 lines
748 B
Go
package cel
|
|
|
|
import (
|
|
"github.com/google/cel-go/cel"
|
|
"github.com/google/cel-go/ext"
|
|
"github.com/kyverno/kyverno/pkg/cel/libs/image"
|
|
"k8s.io/apiserver/pkg/cel/library"
|
|
)
|
|
|
|
func NewEnv() (*cel.Env, error) {
|
|
// create new cel env
|
|
return cel.NewEnv(
|
|
// configure env
|
|
cel.HomogeneousAggregateLiterals(),
|
|
cel.EagerlyValidateDeclarations(true),
|
|
cel.DefaultUTCTimeZone(true),
|
|
cel.CrossTypeNumericComparisons(true),
|
|
// register common libs
|
|
cel.OptionalTypes(),
|
|
ext.Bindings(),
|
|
ext.Encoders(),
|
|
ext.Lists(),
|
|
ext.Math(),
|
|
ext.Protos(),
|
|
ext.Sets(),
|
|
ext.Strings(),
|
|
// register kubernetes libs
|
|
library.CIDR(),
|
|
library.Format(),
|
|
library.IP(),
|
|
library.Lists(),
|
|
library.Regex(),
|
|
library.URLs(),
|
|
image.ImageLib(),
|
|
)
|
|
}
|