X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/678f1f53466c3f2133f63a6e6ad553f5e5d14804..4a919918a4ce37b5290793f02fa959db1c073590:/lib/controller/rpc/conn.go diff --git a/lib/controller/rpc/conn.go b/lib/controller/rpc/conn.go index e07eaf40af..1028da829f 100644 --- a/lib/controller/rpc/conn.go +++ b/lib/controller/rpc/conn.go @@ -8,6 +8,7 @@ import ( "context" "crypto/tls" "encoding/json" + "errors" "fmt" "io" "net" @@ -17,10 +18,19 @@ import ( "time" "git.curoverse.com/arvados.git/sdk/go/arvados" + "git.curoverse.com/arvados.git/sdk/go/auth" ) type TokenProvider func(context.Context) ([]string, error) +func PassthroughTokenProvider(ctx context.Context) ([]string, error) { + if incoming, ok := auth.FromContext(ctx); !ok { + return nil, errors.New("no token provided") + } else { + return incoming.Tokens, nil + } +} + type Conn struct { clusterID string httpClient http.Client @@ -111,6 +121,13 @@ func (conn *Conn) requestAndDecode(ctx context.Context, dst interface{}, ep arva return aClient.RequestAndDecodeContext(ctx, dst, ep.Method, path, body, params) } +func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) { + ep := arvados.EndpointConfigGet + var resp json.RawMessage + err := conn.requestAndDecode(ctx, &resp, ep, nil, nil) + return resp, err +} + func (conn *Conn) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) { ep := arvados.EndpointCollectionCreate var resp arvados.Collection