mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 01:15:46 +08:00

* IAM: Register CoreRole apis
* one line store instantiation
* Small refactor for readability
* Add authorizer for CoreRole
* Nit
* Error strings should not end with punctiation
* Account for error
* Switch to use the local resource client
* error should not start with upper casing
* noopStorageErr should have a name starting with err
* Update workspace
* I don't know why I don't have the same output as the CI 🤷
* Dependency xOwnership
* imports
* Import order
* Rename alias to make it clear this is legacy
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
package noopstorage
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
|
"github.com/grafana/grafana/pkg/storage/unified/resourcepb"
|
|
)
|
|
|
|
var (
|
|
_ resource.StorageBackend = &StorageBackendImpl{}
|
|
|
|
errNoopStorage = errors.New("unavailable functionality")
|
|
)
|
|
|
|
type StorageBackendImpl struct{}
|
|
|
|
func ProvideStorageBackend() *StorageBackendImpl {
|
|
return &StorageBackendImpl{}
|
|
}
|
|
|
|
// GetResourceStats implements resource.StorageBackend.
|
|
func (c *StorageBackendImpl) GetResourceStats(ctx context.Context, namespace string, minCount int) ([]resource.ResourceStats, error) {
|
|
return []resource.ResourceStats{}, errNoopStorage
|
|
}
|
|
|
|
// ListHistory implements resource.StorageBackend.
|
|
func (c *StorageBackendImpl) ListHistory(context.Context, *resourcepb.ListRequest, func(resource.ListIterator) error) (int64, error) {
|
|
return 0, errNoopStorage
|
|
}
|
|
|
|
// ListIterator implements resource.StorageBackend.
|
|
func (c *StorageBackendImpl) ListIterator(context.Context, *resourcepb.ListRequest, func(resource.ListIterator) error) (int64, error) {
|
|
return 0, errNoopStorage
|
|
}
|
|
|
|
// ReadResource implements resource.StorageBackend.
|
|
func (c *StorageBackendImpl) ReadResource(_ context.Context, req *resourcepb.ReadRequest) *resource.BackendReadResponse {
|
|
return &resource.BackendReadResponse{
|
|
Key: req.GetKey(),
|
|
Error: &resourcepb.ErrorResult{Code: http.StatusForbidden, Message: errNoopStorage.Error()},
|
|
}
|
|
}
|
|
|
|
// WatchWriteEvents implements resource.StorageBackend.
|
|
func (c *StorageBackendImpl) WatchWriteEvents(ctx context.Context) (<-chan *resource.WrittenEvent, error) {
|
|
stream := make(chan *resource.WrittenEvent, 10)
|
|
return stream, nil
|
|
}
|
|
|
|
// WriteEvent implements resource.StorageBackend.
|
|
func (c *StorageBackendImpl) WriteEvent(context.Context, resource.WriteEvent) (int64, error) {
|
|
return 0, errNoopStorage
|
|
}
|