aclsvc/v2: Add toRequestContext() helper
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
d9ab944c22
commit
fb37fbf1d6
2 changed files with 14 additions and 21 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
sessionV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
sessionV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -150,3 +151,11 @@ func unmarshalPublicKeyWithOwner(rawKey []byte) (*user.ID, *keys.PublicKey, erro
|
||||||
|
|
||||||
return &idSender, key, nil
|
return &idSender, key, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r RequestInfo) toRequestContext() *object.RequestContext {
|
||||||
|
return &object.RequestContext{
|
||||||
|
Namespace: r.ContainerNamespace(),
|
||||||
|
SenderKey: r.SenderKey(),
|
||||||
|
Role: r.RequestRole(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -118,11 +118,7 @@ func (w *wrappedGetObjectStream) Context() context.Context {
|
||||||
func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, reqInfo RequestInfo) object.GetObjectStream {
|
func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, reqInfo RequestInfo) object.GetObjectStream {
|
||||||
return &wrappedGetObjectStream{
|
return &wrappedGetObjectStream{
|
||||||
GetObjectStream: getObjectStream,
|
GetObjectStream: getObjectStream,
|
||||||
requestContext: &object.RequestContext{
|
requestContext: reqInfo.toRequestContext(),
|
||||||
Namespace: reqInfo.ContainerNamespace(),
|
|
||||||
SenderKey: reqInfo.SenderKey(),
|
|
||||||
Role: reqInfo.RequestRole(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,11 +137,7 @@ func (w *wrappedRangeStream) Context() context.Context {
|
||||||
func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo RequestInfo) object.GetObjectRangeStream {
|
func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo RequestInfo) object.GetObjectRangeStream {
|
||||||
return &wrappedRangeStream{
|
return &wrappedRangeStream{
|
||||||
GetObjectRangeStream: rangeStream,
|
GetObjectRangeStream: rangeStream,
|
||||||
requestContext: &object.RequestContext{
|
requestContext: reqInfo.toRequestContext(),
|
||||||
Namespace: reqInfo.ContainerNamespace(),
|
|
||||||
SenderKey: reqInfo.SenderKey(),
|
|
||||||
Role: reqInfo.RequestRole(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,12 +155,8 @@ func (w *wrappedSearchStream) Context() context.Context {
|
||||||
|
|
||||||
func newWrappedSearchStream(searchStream object.SearchStream, reqInfo RequestInfo) object.SearchStream {
|
func newWrappedSearchStream(searchStream object.SearchStream, reqInfo RequestInfo) object.SearchStream {
|
||||||
return &wrappedSearchStream{
|
return &wrappedSearchStream{
|
||||||
SearchStream: searchStream,
|
SearchStream: searchStream,
|
||||||
requestContext: &object.RequestContext{
|
requestContext: reqInfo.toRequestContext(),
|
||||||
Namespace: reqInfo.ContainerNamespace(),
|
|
||||||
SenderKey: reqInfo.SenderKey(),
|
|
||||||
Role: reqInfo.RequestRole(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,11 +445,7 @@ func (b Service) GetRange(request *objectV2.GetRangeRequest, stream object.GetOb
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestContext(ctx context.Context, reqInfo RequestInfo) context.Context {
|
func requestContext(ctx context.Context, reqInfo RequestInfo) context.Context {
|
||||||
return object.NewRequestContext(ctx, &object.RequestContext{
|
return object.NewRequestContext(ctx, reqInfo.toRequestContext())
|
||||||
Namespace: reqInfo.ContainerNamespace(),
|
|
||||||
SenderKey: reqInfo.SenderKey(),
|
|
||||||
Role: reqInfo.RequestRole(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Service) GetRangeHash(
|
func (b Service) GetRangeHash(
|
||||||
|
|
Loading…
Reference in a new issue