refactor(unified-storage): move generated protos to own pkg (#105356)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/resourcepb"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/sql/db"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/sql/dbutil"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/sql/sqltemplate"
|
||||
@@ -25,12 +26,12 @@ func (b *backend) SupportsSignedURLs() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *backend) PutResourceBlob(ctx context.Context, req *resource.PutBlobRequest) (*resource.PutBlobResponse, error) {
|
||||
func (b *backend) PutResourceBlob(ctx context.Context, req *resourcepb.PutBlobRequest) (*resourcepb.PutBlobResponse, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"PutResourceBlob")
|
||||
defer span.End()
|
||||
|
||||
if req.Method == resource.PutBlobRequest_HTTP {
|
||||
return &resource.PutBlobResponse{
|
||||
if req.Method == resourcepb.PutBlobRequest_HTTP {
|
||||
return &resourcepb.PutBlobResponse{
|
||||
Error: resource.NewBadRequestError("signed url upload not supported"),
|
||||
}, nil
|
||||
}
|
||||
@@ -49,7 +50,7 @@ func (b *backend) PutResourceBlob(ctx context.Context, req *resource.PutBlobRequ
|
||||
info.SetContentType(req.ContentType)
|
||||
|
||||
if info.Size < 1 {
|
||||
return &resource.PutBlobResponse{
|
||||
return &resourcepb.PutBlobResponse{
|
||||
Error: resource.NewBadRequestError("empty content"),
|
||||
}, nil
|
||||
}
|
||||
@@ -68,11 +69,11 @@ func (b *backend) PutResourceBlob(ctx context.Context, req *resource.PutBlobRequ
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return &resource.PutBlobResponse{
|
||||
return &resourcepb.PutBlobResponse{
|
||||
Error: resource.AsErrorResult(err),
|
||||
}, nil
|
||||
}
|
||||
return &resource.PutBlobResponse{
|
||||
return &resourcepb.PutBlobResponse{
|
||||
Uid: info.UID,
|
||||
Size: info.Size,
|
||||
MimeType: info.MimeType,
|
||||
@@ -81,17 +82,17 @@ func (b *backend) PutResourceBlob(ctx context.Context, req *resource.PutBlobRequ
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (b *backend) GetResourceBlob(ctx context.Context, key *resource.ResourceKey, info *utils.BlobInfo, mustProxy bool) (*resource.GetBlobResponse, error) {
|
||||
func (b *backend) GetResourceBlob(ctx context.Context, key *resourcepb.ResourceKey, info *utils.BlobInfo, mustProxy bool) (*resourcepb.GetBlobResponse, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"GetResourceBlob")
|
||||
defer span.End()
|
||||
|
||||
if info == nil {
|
||||
return &resource.GetBlobResponse{
|
||||
return &resourcepb.GetBlobResponse{
|
||||
Error: resource.NewBadRequestError("missing blob info"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
rsp := &resource.GetBlobResponse{}
|
||||
rsp := &resourcepb.GetBlobResponse{}
|
||||
err := b.db.WithTx(ctx, ReadCommitted, func(ctx context.Context, tx db.Tx) error {
|
||||
rows, err := dbutil.QueryRows(ctx, tx, sqlResourceBlobQuery, sqlResourceBlobQueryRequest{
|
||||
SQLTemplate: sqltemplate.New(b.dialect),
|
||||
@@ -109,7 +110,7 @@ func (b *backend) GetResourceBlob(ctx context.Context, key *resource.ResourceKey
|
||||
}
|
||||
return err
|
||||
}
|
||||
rsp.Error = &resource.ErrorResult{
|
||||
rsp.Error = &resourcepb.ErrorResult{
|
||||
Code: http.StatusNotFound,
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user