From ac5dab220e20110bfd8bcece46cf13442ab7fa09 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 21 Jan 2025 11:13:21 +0300 Subject: [PATCH] fix panic... hopefully --- .../apis/provisioning/resources/object.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/registry/apis/provisioning/resources/object.go b/pkg/registry/apis/provisioning/resources/object.go index 2d511d7090b..baa585f4cf3 100644 --- a/pkg/registry/apis/provisioning/resources/object.go +++ b/pkg/registry/apis/provisioning/resources/object.go @@ -2,6 +2,7 @@ package resources import ( "context" + "fmt" provisioning "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1" "github.com/grafana/grafana/pkg/storage/unified/resource" @@ -18,6 +19,9 @@ type ResourceListerFromSearch struct { } func NewResourceLister(index resource.RepositoryIndexClient) ResourceLister { + if index == nil { + return &errorLister{} + } return &ResourceListerFromSearch{ index: index, } @@ -76,3 +80,15 @@ func (o *ResourceListerFromSearch) Stats(ctx context.Context, namespace, reposit } return stats, nil } + +type errorLister struct{} + +// List implements ResourceLister. +func (e *errorLister) List(ctx context.Context, namespace string, repository string) (*provisioning.ResourceList, error) { + return nil, fmt.Errorf("missing search index") +} + +// Stats implements ResourceLister. +func (e *errorLister) Stats(ctx context.Context, namespace string, repository string) (*provisioning.ResourceStats, error) { + return nil, fmt.Errorf("missing search index") +}