diff --git a/pkg/engine/assert/assert.go b/pkg/engine/assert/assert.go index cfd8ac95..a778d77d 100644 --- a/pkg/engine/assert/assert.go +++ b/pkg/engine/assert/assert.go @@ -7,18 +7,10 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" ) -func Validate(ctx context.Context, assertion interface{}, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { - return validate(ctx, nil, assertion, value, bindings) -} - func Assert(ctx context.Context, assertion Assertion, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { return assert(ctx, nil, assertion, value, bindings) } -func validate(ctx context.Context, path *field.Path, assertion interface{}, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { - return assert(ctx, path, Parse(ctx, assertion), value, bindings) -} - func assert(ctx context.Context, path *field.Path, assertion Assertion, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { return assertion.assert(ctx, path, value, bindings) } diff --git a/pkg/engine/assert/match.go b/pkg/engine/assert/match.go index 1b77d4fc..c3b8aaf3 100644 --- a/pkg/engine/assert/match.go +++ b/pkg/engine/assert/match.go @@ -22,7 +22,7 @@ func MatchAssert(ctx context.Context, path *field.Path, match *v1alpha1.Assert, var fails []error path := path.Child("any") for i, assertion := range match.Any { - checkFails, err := validate(ctx, path.Index(i).Child("check"), assertion.Check.Value, actual, bindings) + checkFails, err := assert(ctx, path.Index(i).Child("check"), Parse(ctx, assertion.Check.Value), actual, bindings) if err != nil { return fails, err } @@ -46,7 +46,7 @@ func MatchAssert(ctx context.Context, path *field.Path, match *v1alpha1.Assert, var fails []error path := path.Child("all") for i, assertion := range match.All { - checkFails, err := validate(ctx, path.Index(i).Child("check"), assertion.Check.Value, actual, bindings) + checkFails, err := assert(ctx, path.Index(i).Child("check"), Parse(ctx, assertion.Check.Value), actual, bindings) if err != nil { return fails, err } @@ -92,7 +92,7 @@ func Match(ctx context.Context, path *field.Path, match *v1alpha1.Match, actual func MatchAny(ctx context.Context, path *field.Path, assertions []v1alpha1.Any, actual interface{}, bindings binding.Bindings) (field.ErrorList, error) { var errs field.ErrorList for i, assertion := range assertions { - _errs, err := validate(ctx, path.Index(i), assertion.Value, actual, bindings) + _errs, err := assert(ctx, path.Index(i), Parse(ctx, assertion.Value), actual, bindings) if err != nil { return errs, err } @@ -107,7 +107,7 @@ func MatchAny(ctx context.Context, path *field.Path, assertions []v1alpha1.Any, func MatchAll(ctx context.Context, path *field.Path, assertions []v1alpha1.Any, actual interface{}, bindings binding.Bindings) (field.ErrorList, error) { var errs field.ErrorList for i, assertion := range assertions { - _errs, err := validate(ctx, path.Index(i), assertion.Value, actual, bindings) + _errs, err := assert(ctx, path.Index(i), Parse(ctx, assertion.Value), actual, bindings) if err != nil { return errs, err }