From de139b30c027b3d057da2525841d38c652281313 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 9 Feb 2024 13:46:02 +0300 Subject: [PATCH] aclsvc/v2: Add toRequestContext() helper Signed-off-by: Evgenii Stratonikov --- pkg/services/object/acl/v2/request.go | 11 +++++++++ pkg/services/object/acl/v2/service.go | 34 ++++----------------------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/pkg/services/object/acl/v2/request.go b/pkg/services/object/acl/v2/request.go index 74279e453..d003a0e6d 100644 --- a/pkg/services/object/acl/v2/request.go +++ b/pkg/services/object/acl/v2/request.go @@ -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(), + } +} diff --git a/pkg/services/object/acl/v2/service.go b/pkg/services/object/acl/v2/service.go index a352af911..1968edf35 100644 --- a/pkg/services/object/acl/v2/service.go +++ b/pkg/services/object/acl/v2/service.go @@ -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(