[#1428] node/acl: Make container ID as required param
Change pointer to value in request information since requests could not exist without container ID. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
6cb9c13c5e
commit
d69eb2aaf3
5 changed files with 14 additions and 21 deletions
|
@ -20,9 +20,9 @@ import (
|
|||
|
||||
var errMissingContainerID = errors.New("missing container ID")
|
||||
|
||||
func getContainerIDFromRequest(req interface{}) (*containerIDSDK.ID, error) {
|
||||
func getContainerIDFromRequest(req interface{}) (containerIDSDK.ID, error) {
|
||||
var idV2 *refsV2.ContainerID
|
||||
id := new(containerIDSDK.ID)
|
||||
var id containerIDSDK.ID
|
||||
|
||||
switch v := req.(type) {
|
||||
case *objectV2.GetRequest:
|
||||
|
@ -30,7 +30,7 @@ func getContainerIDFromRequest(req interface{}) (*containerIDSDK.ID, error) {
|
|||
case *objectV2.PutRequest:
|
||||
part, ok := v.GetBody().GetObjectPart().(*objectV2.PutObjectPartInit)
|
||||
if !ok {
|
||||
return nil, errors.New("can't get container ID in chunk")
|
||||
return containerIDSDK.ID{}, errors.New("can't get container ID in chunk")
|
||||
}
|
||||
|
||||
idV2 = part.GetHeader().GetContainerID()
|
||||
|
@ -45,11 +45,11 @@ func getContainerIDFromRequest(req interface{}) (*containerIDSDK.ID, error) {
|
|||
case *objectV2.GetRangeHashRequest:
|
||||
idV2 = v.GetBody().GetAddress().GetContainerID()
|
||||
default:
|
||||
return nil, errors.New("unknown request type")
|
||||
return containerIDSDK.ID{}, errors.New("unknown request type")
|
||||
}
|
||||
|
||||
if idV2 == nil {
|
||||
return nil, errMissingContainerID
|
||||
return containerIDSDK.ID{}, errMissingContainerID
|
||||
}
|
||||
|
||||
return id, id.ReadFromV2(*idV2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue