forked from TrueCloudLab/frostfs-node
[#934] ape: Transform empty namespace within chainbase
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
483a67b170
commit
4352bd0e8e
2 changed files with 9 additions and 6 deletions
|
@ -115,6 +115,10 @@ func getTargetBucket(tx *bbolt.Tx, name chain.Name, target policyengine.Target)
|
||||||
return nil, fmt.Errorf("%w: %w: %c", policyengine.ErrChainNotFound, ErrTargetTypeBucketNotFound, target.Type)
|
return nil, fmt.Errorf("%w: %w: %c", policyengine.ErrChainNotFound, ErrTargetTypeBucketNotFound, target.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if target.Type == policyengine.Namespace && target.Name == "" {
|
||||||
|
target.Name = "root"
|
||||||
|
}
|
||||||
|
|
||||||
rbucket := typeBucket.Bucket([]byte(target.Name))
|
rbucket := typeBucket.Bucket([]byte(target.Name))
|
||||||
if rbucket == nil {
|
if rbucket == nil {
|
||||||
return nil, fmt.Errorf("%w: %w: %s", policyengine.ErrChainNotFound, ErrTargetNameBucketNotFound, target.Name)
|
return nil, fmt.Errorf("%w: %w: %s", policyengine.ErrChainNotFound, ErrTargetNameBucketNotFound, target.Name)
|
||||||
|
@ -146,6 +150,10 @@ func getTargetBucketCreateIfEmpty(tx *bbolt.Tx, name chain.Name, target policyen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if target.Type == policyengine.Namespace && target.Name == "" {
|
||||||
|
target.Name = "root"
|
||||||
|
}
|
||||||
|
|
||||||
rbucket := typeBucket.Bucket([]byte(target.Name))
|
rbucket := typeBucket.Bucket([]byte(target.Name))
|
||||||
if rbucket == nil {
|
if rbucket == nil {
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -18,12 +18,7 @@ func apeTarget(chainTarget *control.ChainTarget) (engine.Target, error) {
|
||||||
case control.ChainTarget_CONTAINER:
|
case control.ChainTarget_CONTAINER:
|
||||||
return engine.ContainerTarget(chainTarget.GetName()), nil
|
return engine.ContainerTarget(chainTarget.GetName()), nil
|
||||||
case control.ChainTarget_NAMESPACE:
|
case control.ChainTarget_NAMESPACE:
|
||||||
namespace := chainTarget.GetName()
|
return engine.NamespaceTarget(chainTarget.GetName()), nil
|
||||||
// If namespace is empty, we take it for root namespace.
|
|
||||||
if namespace == "" {
|
|
||||||
namespace = "root"
|
|
||||||
}
|
|
||||||
return engine.NamespaceTarget(namespace), nil
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
return engine.Target{}, status.Error(codes.InvalidArgument,
|
return engine.Target{}, status.Error(codes.InvalidArgument,
|
||||||
|
|
Loading…
Reference in a new issue