fix panic... hopefully

This commit is contained in:
Ryan McKinley committed 2025-01-21 11:13:21 +03:00
1 parent f66c9901a1
commit ac5dab220e
1 file changed
+16
@@ -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")
}