diff --git a/pkg/core/assertion/assertion.go b/pkg/core/assertion/assertion.go index b0322b14..28b8af42 100644 --- a/pkg/core/assertion/assertion.go +++ b/pkg/core/assertion/assertion.go @@ -8,9 +8,9 @@ import ( "github.com/jmespath-community/go-jmespath/pkg/binding" "github.com/kyverno/kyverno-json/pkg/core/expression" + "github.com/kyverno/kyverno-json/pkg/core/matching" "github.com/kyverno/kyverno-json/pkg/core/projection" "github.com/kyverno/kyverno-json/pkg/core/templating" - "github.com/kyverno/kyverno-json/pkg/engine/match" reflectutils "github.com/kyverno/kyverno-json/pkg/utils/reflect" "k8s.io/apimachinery/pkg/util/validation/field" ) @@ -206,7 +206,7 @@ func parseScalar(assertion any, compiler templating.Compiler) (node, error) { expected = projected } var errs field.ErrorList - if match, err := match.Match(expected, value); err != nil { + if match, err := matching.Match(expected, value); err != nil { return nil, field.InternalError(path, err) } else if !match { errs = append(errs, field.Invalid(path, value, expectValueMessage(expected))) diff --git a/pkg/utils/reflect/match.go b/pkg/core/matching/equal.go similarity index 78% rename from pkg/utils/reflect/match.go rename to pkg/core/matching/equal.go index 1a35c6d4..0ad5249b 100644 --- a/pkg/utils/reflect/match.go +++ b/pkg/core/matching/equal.go @@ -1,11 +1,13 @@ -package reflect +package matching import ( "fmt" "reflect" + + reflectutils "github.com/kyverno/kyverno-json/pkg/utils/reflect" ) -func MatchScalar(expected, actual any) (bool, error) { +func Equal(expected, actual any) (bool, error) { if actual == nil && expected == nil { return true, nil } else if actual == nil && expected != nil { @@ -42,5 +44,5 @@ func MatchScalar(expected, actual any) (bool, error) { return a == e, nil } } - return false, fmt.Errorf("types are not comparable, %s - %s", GetKind(expected), GetKind(actual)) + return false, fmt.Errorf("types are not comparable, %s - %s", reflectutils.GetKind(expected), reflectutils.GetKind(actual)) } diff --git a/pkg/engine/match/match.go b/pkg/core/matching/match.go similarity index 95% rename from pkg/engine/match/match.go rename to pkg/core/matching/match.go index c433318b..98bc7f27 100644 --- a/pkg/engine/match/match.go +++ b/pkg/core/matching/match.go @@ -1,4 +1,4 @@ -package match +package matching import ( "fmt" @@ -44,5 +44,5 @@ func Match(expected, actual any) (bool, error) { return true, nil } } - return reflectutils.MatchScalar(expected, actual) + return Equal(expected, actual) } diff --git a/pkg/utils/reflect/number.go b/pkg/core/matching/number.go similarity index 94% rename from pkg/utils/reflect/number.go rename to pkg/core/matching/number.go index 74f33a1b..942bbcdf 100644 --- a/pkg/utils/reflect/number.go +++ b/pkg/core/matching/number.go @@ -1,4 +1,4 @@ -package reflect +package matching import ( "reflect" diff --git a/pkg/utils/reflect/number_test.go b/pkg/core/matching/number_test.go similarity index 98% rename from pkg/utils/reflect/number_test.go rename to pkg/core/matching/number_test.go index d8a99779..3a167782 100644 --- a/pkg/utils/reflect/number_test.go +++ b/pkg/core/matching/number_test.go @@ -1,4 +1,4 @@ -package reflect +package matching import ( "reflect"