Skip to content

Commit

Permalink
chore: rename compiledVariable struct
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusfm committed Mar 12, 2024
1 parent 8faebb3 commit 417cc14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/validator/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 417cc14

Please sign in to comment.