diff --git a/pkg/event/event.go b/pkg/event/event.go index 4fb63351d..fe3b7d573 100644 --- a/pkg/event/event.go +++ b/pkg/event/event.go @@ -35,7 +35,6 @@ func NewRecorder(c kclient.Client) RecorderFunc { } // Set a generated name based on the event content. - // NOTE: This is validated server-side, so it's important that this is done, just before sending the request. id, err := ContentID(e) if err != nil { return fmt.Errorf("failed to generate event name from content: %w", err) diff --git a/pkg/server/registry/apigroups/acorn/events/storage.go b/pkg/server/registry/apigroups/acorn/events/storage.go index 5b19e8145..c45beb35e 100644 --- a/pkg/server/registry/apigroups/acorn/events/storage.go +++ b/pkg/server/registry/apigroups/acorn/events/storage.go @@ -23,7 +23,6 @@ func NewStorage(c kclient.WithWatch) rest.Storage { return stores.NewBuilder(c.Scheme(), &apiv1.Event{}). WithTableConverter(tables.EventConverter). - WithValidateName(new(validator)). WithCompleteCRUD(strategy). Build() } diff --git a/pkg/server/registry/apigroups/acorn/events/validator.go b/pkg/server/registry/apigroups/acorn/events/validator.go deleted file mode 100644 index 81e0edf52..000000000 --- a/pkg/server/registry/apigroups/acorn/events/validator.go +++ /dev/null @@ -1,36 +0,0 @@ -package events - -import ( - "context" - "fmt" - - apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1" - "github.com/acorn-io/runtime/pkg/event" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" -) - -type validator struct{} - -func (validator) ValidateName(_ context.Context, obj runtime.Object) (result field.ErrorList) { - e := obj.(*apiv1.Event) - - id, err := event.ContentID(e) - if err != nil { - result = append(result, field.InternalError( - field.NewPath("metadata", "name"), - fmt.Errorf("failed to generate content ID for event: %w", err), - )) - return - } - - if e.Name != id { - result = append(result, field.Invalid( - field.NewPath("metadata", "name"), - e.Name, - fmt.Sprintf("name should be %q", id), - )) - } - - return -}