From c539be48d8992b329bbed3fa90b79bc43de2e406 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 19 Aug 2025 21:23:32 +0300 Subject: [PATCH] remove dummy validatio --- pkg/registry/apis/datasource/admission.go | 53 ----------------------- 1 file changed, 53 deletions(-) delete mode 100644 pkg/registry/apis/datasource/admission.go diff --git a/pkg/registry/apis/datasource/admission.go b/pkg/registry/apis/datasource/admission.go deleted file mode 100644 index 976103a6ade..00000000000 --- a/pkg/registry/apis/datasource/admission.go +++ /dev/null @@ -1,53 +0,0 @@ -package datasource - -import ( - "context" - "fmt" - - "k8s.io/apiserver/pkg/admission" - "k8s.io/kube-openapi/pkg/validation/strfmt" - "k8s.io/kube-openapi/pkg/validation/validate" - - datasourceV0 "github.com/grafana/grafana/pkg/apis/datasource/v0alpha1" -) - -// Validate implements builder.APIGroupValidation. -func (b *DataSourceAPIBuilder) Validate(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) (err error) { - fmt.Printf("Calling validate???\n") - return nil -} - -// Mutate implements builder.APIGroupMutation. -func (b *DataSourceAPIBuilder) Mutate(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) (err error) { - obj := a.GetObject() - - if b.schemaProvider == nil || obj == nil || a.GetOperation() == admission.Connect { - return nil // This is normal for sub-resource - } - - ds, ok := obj.(*datasourceV0.DataSource) - if !ok { - return fmt.Errorf("expected datasource object") - } - - info, err := b.schemaProvider() - if err != nil { - return err - } - if info.DataSourceSpec != nil { - validate := validate.NewSchemaValidator(info.DataSourceSpec, nil, "", strfmt.Default) - results := validate.Validate(ds.Spec) // will fail! - for _, err := range results.Errors { - fmt.Printf("ERROR: %+v\n", err) - } - for _, err := range results.Warnings { - fmt.Printf("WARNING: %+v\n", err) - } - } - if len(info.SecureValues) > 0 { - fmt.Printf("TODO, validate secure values") - } - - // TODO... call the plugin mutation hook - return nil // TODO! replace with app helpers -}