Files
opencloud/services/search/pkg/content/retriever.go
Jörn Friedrich Dreyer fad94d2038 bump mockery, add test stub for oidc_auth.go, align mock generation (#8321)
* bump mockery, add test stub for oidc_auth.go

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use .mockery.yaml for all mocks

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* drop legacy go:generate mockery

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* align mock placement

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2024-02-01 10:07:44 +01:00

30 lines
644 B
Go

package content
import (
"context"
"io"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"google.golang.org/grpc/metadata"
)
// Retriever is the interface that wraps the basic Retrieve method. 🐕
// It requests and then returns a resource from the underlying storage.
type Retriever interface {
Retrieve(ctx context.Context, rID *provider.ResourceId) (io.ReadCloser, error)
}
func contextGet(ctx context.Context, k string) (string, bool) {
md, ok := metadata.FromOutgoingContext(ctx)
if !ok {
return "", false
}
token, ok := md[k]
if len(token) == 0 || !ok {
return "", false
}
return token[0], ok
}