From 417cc1427e64dd8334ad85a6fac91943cfefb88f Mon Sep 17 00:00:00 2001 From: Matheus Moraes Date: Tue, 12 Mar 2024 13:55:48 -0300 Subject: [PATCH] chore: rename compiledVariable struct --- pkg/validator/compiler.go | 6 +++--- pkg/validator/validator.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/validator/compiler.go b/pkg/validator/compiler.go index 5fa024b..b9b0e1d 100644 --- a/pkg/validator/compiler.go +++ b/pkg/validator/compiler.go @@ -94,14 +94,14 @@ func newEnv(check types.Check) (*cel.Env, error) { return cel.NewEnv(opts...) } -func compileVariables(env *cel.Env, vars []types.Variable) ([]compiledVariables, error) { - variables := make([]compiledVariables, 0, len(vars)) +func compileVariables(env *cel.Env, vars []types.Variable) ([]compiledVariable, error) { + variables := make([]compiledVariable, 0, len(vars)) for _, v := range vars { prg, err := compileExpression(env, v.Expression, cel.AnyType) if err != nil { return nil, fmt.Errorf("variables[%q].expression: %s", v.Name, err) } - variables = append(variables, compiledVariables{name: v.Name, program: prg}) + variables = append(variables, compiledVariable{name: v.Name, program: prg}) } return variables, nil } diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index 0e2e44c..d9911f8 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -33,10 +33,10 @@ type CELValidator struct { programs []cel.Program apiVersions []string kubeVersion *version.Info - variables []compiledVariables + variables []compiledVariable } -type compiledVariables struct { +type compiledVariable struct { name string program cel.Program } @@ -74,7 +74,7 @@ func (r *CELValidator) Validate(obj unstructured.Unstructured, params any) (bool return true, "", nil } -func callback(v compiledVariables, activation any) lazy.GetFieldFunc { +func callback(v compiledVariable, activation any) lazy.GetFieldFunc { return func(_ *lazy.MapValue) ref.Val { val, _, err := v.program.Eval(activation) if err != nil {