aclsvc/v2: Add toRequestContext() helper

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-02-09 13:46:02 +03:00
parent d9ab944c22
commit fb37fbf1d6
2 changed files with 14 additions and 21 deletions

View file

@ -5,6 +5,7 @@ import (
"fmt"
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/container/acl"
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
}
func (r RequestInfo) toRequestContext() *object.RequestContext {
return &object.RequestContext{
Namespace: r.ContainerNamespace(),
SenderKey: r.SenderKey(),
Role: r.RequestRole(),
}
}

View file

@ -118,11 +118,7 @@ func (w *wrappedGetObjectStream) Context() context.Context {
func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, reqInfo RequestInfo) object.GetObjectStream {
return &wrappedGetObjectStream{
GetObjectStream: getObjectStream,
requestContext: &object.RequestContext{
Namespace: reqInfo.ContainerNamespace(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
},
requestContext: reqInfo.toRequestContext(),
}
}
@ -141,11 +137,7 @@ func (w *wrappedRangeStream) Context() context.Context {
func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo RequestInfo) object.GetObjectRangeStream {
return &wrappedRangeStream{
GetObjectRangeStream: rangeStream,
requestContext: &object.RequestContext{
Namespace: reqInfo.ContainerNamespace(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
},
requestContext: reqInfo.toRequestContext(),
}
}
@ -163,12 +155,8 @@ func (w *wrappedSearchStream) Context() context.Context {
func newWrappedSearchStream(searchStream object.SearchStream, reqInfo RequestInfo) object.SearchStream {
return &wrappedSearchStream{
SearchStream: searchStream,
requestContext: &object.RequestContext{
Namespace: reqInfo.ContainerNamespace(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
},
SearchStream: searchStream,
requestContext: reqInfo.toRequestContext(),
}
}
@ -457,11 +445,7 @@ func (b Service) GetRange(request *objectV2.GetRangeRequest, stream object.GetOb
}
func requestContext(ctx context.Context, reqInfo RequestInfo) context.Context {
return object.NewRequestContext(ctx, &object.RequestContext{
Namespace: reqInfo.ContainerNamespace(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
})
return object.NewRequestContext(ctx, reqInfo.toRequestContext())
}
func (b Service) GetRangeHash(