From e0281c3b34a1fc4fcfe4d5a84ef824fffb01cb92 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 6 Apr 2022 09:19:05 +0300 Subject: [PATCH] [#191] pool: use bearer token Signed-off-by: Denis Kirillov --- go.mod | 1 - pool/pool.go | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 437be290..0ea096ef 100644 --- a/go.mod +++ b/go.mod @@ -13,5 +13,4 @@ require ( github.com/nspcc-dev/neofs-api-go/v2 v2.12.1 github.com/stretchr/testify v1.7.0 go.uber.org/zap v1.18.1 - google.golang.org/grpc v1.41.0 ) diff --git a/pool/pool.go b/pool/pool.go index a43e7287..f53b7065 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -1064,6 +1064,10 @@ func (p *Pool) DeleteObject(ctx context.Context, prm PrmObjectDelete) error { cliPrm.ByID(*obj) } + if prm.btoken != nil { + cliPrm.WithBearerToken(*prm.btoken) + } + cliPrm.UseKey(*cc.key) return p.callWithRetry(&cc, func() error { @@ -1122,6 +1126,10 @@ func (p *Pool) GetObject(ctx context.Context, prm PrmObjectGet) (*ResGetObject, cliPrm.ByID(*obj) } + if prm.btoken != nil { + cliPrm.WithBearerToken(*prm.btoken) + } + var res ResGetObject err = p.callWithRetry(&cc, func() error { @@ -1174,6 +1182,10 @@ func (p *Pool) HeadObject(ctx context.Context, prm PrmObjectHead) (*object.Objec cliPrm.ByID(*obj) } + if prm.btoken != nil { + cliPrm.WithBearerToken(*prm.btoken) + } + cliPrm.UseKey(*cc.key) var obj object.Object @@ -1248,6 +1260,10 @@ func (p *Pool) ObjectRange(ctx context.Context, prm PrmObjectRange) (*ResObjectR cliPrm.ByID(*obj) } + if prm.btoken != nil { + cliPrm.WithBearerToken(*prm.btoken) + } + var res ResObjectRange err = p.callWithRetry(&cc, func() error { @@ -1320,6 +1336,10 @@ func (p *Pool) SearchObjects(ctx context.Context, prm PrmObjectSearch) (*ResObje cliPrm.InContainer(prm.cnrID) cliPrm.SetFilters(prm.filters) + if prm.btoken != nil { + cliPrm.WithBearerToken(*prm.btoken) + } + var cc callContextWithRetry cc.Context = ctx