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 81880f92fb
commit de139b30c0
2 changed files with 16 additions and 29 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"
@ -157,3 +158,13 @@ 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(),
ContainerOwner: r.ContainerOwner(),
SenderKey: r.SenderKey(),
Role: r.RequestRole(),
SoftAPECheck: r.IsSoftAPECheck(),
}
}

View file

@ -118,13 +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(),
ContainerOwner: reqInfo.ContainerOwner(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
SoftAPECheck: reqInfo.IsSoftAPECheck(),
},
requestContext: reqInfo.toRequestContext(),
}
}
@ -143,13 +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(),
ContainerOwner: reqInfo.ContainerOwner(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
SoftAPECheck: reqInfo.IsSoftAPECheck(),
},
requestContext: reqInfo.toRequestContext(),
}
}
@ -167,14 +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(),
ContainerOwner: reqInfo.ContainerOwner(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
SoftAPECheck: reqInfo.IsSoftAPECheck(),
},
SearchStream: searchStream,
requestContext: reqInfo.toRequestContext(),
}
}
@ -473,13 +455,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(),
ContainerOwner: reqInfo.ContainerOwner(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
SoftAPECheck: reqInfo.IsSoftAPECheck(),
})
return object.NewRequestContext(ctx, reqInfo.toRequestContext())
}
func (b Service) GetRangeHash(