From f35f5b6d1c47db3cfd624d090a3706ac616191f6 Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Wed, 22 Nov 2023 08:16:17 -0500 Subject: [PATCH] fixed schema validation. Has it ever worked? Signed-off-by: raffaelespazzoli --- pkg/util/lockedresourcecontroller/locked-resource-manager.go | 2 +- pkg/util/templates/templates.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/util/lockedresourcecontroller/locked-resource-manager.go b/pkg/util/lockedresourcecontroller/locked-resource-manager.go index 69c6c0d..fdc0431 100644 --- a/pkg/util/lockedresourcecontroller/locked-resource-manager.go +++ b/pkg/util/lockedresourcecontroller/locked-resource-manager.go @@ -338,7 +338,7 @@ func (lrm *LockedResourceManager) validateLockedResources(lockedResources []lock result = multierror.Append(result, errors.New("resource type:"+lockedResource.Unstructured.GroupVersionKind().String()+"not defined")) continue } - err = templates.ValidateUnstructured(ctx, &lockedResource.Unstructured, schemaValidation.(*validation.NullSchema)) + err = templates.ValidateUnstructured(ctx, &lockedResource.Unstructured, schemaValidation) if err != nil { lrm.log.Error(err, "unable to validate", "unstructured", lockedResource.Unstructured) result = multierror.Append(result, err) diff --git a/pkg/util/templates/templates.go b/pkg/util/templates/templates.go index b2f0f89..31ce13e 100644 --- a/pkg/util/templates/templates.go +++ b/pkg/util/templates/templates.go @@ -107,7 +107,7 @@ func ProcessTemplateArray(context context.Context, data interface{}, template *t // ValidateUnstructured validates the content of an unstructured against an openapi schema. // the schema is intended to be retrieved from a running instance of kubernetes, but other usages are possible. // requires a context with log -func ValidateUnstructured(context context.Context, obj *unstructured.Unstructured, validationSchema *validation.NullSchema) error { +func ValidateUnstructured(context context.Context, obj *unstructured.Unstructured, validationSchema validation.Schema) error { log := log.FromContext(context) bb, err := obj.MarshalJSON() if err != nil {