forked from TrueCloudLab/frostfs-node
[#976] ape: Update dependency
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
7ed07d2dfd
commit
2d595ec15f
3 changed files with 29 additions and 12 deletions
4
go.mod
4
go.mod
|
@ -5,11 +5,11 @@ go 1.20
|
||||||
require (
|
require (
|
||||||
code.gitea.io/sdk/gitea v0.17.1
|
code.gitea.io/sdk/gitea v0.17.1
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240215124401-634e24aba715
|
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240215124401-634e24aba715
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.18.1-0.20240115082915-f2a82aa635aa
|
git.frostfs.info/TrueCloudLab/frostfs-contract v0.19.0
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20231101111734-b3ad3335ff65
|
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20231101111734-b3ad3335ff65
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20240301150205-6fe4e2541d0b
|
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20240301150205-6fe4e2541d0b
|
||||||
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
||||||
git.frostfs.info/TrueCloudLab/policy-engine v0.0.0-20240304151211-839f22e1a36d
|
git.frostfs.info/TrueCloudLab/policy-engine v0.0.0-20240307151106-2ec958cbfdfd
|
||||||
git.frostfs.info/TrueCloudLab/tzhash v1.8.0
|
git.frostfs.info/TrueCloudLab/tzhash v1.8.0
|
||||||
git.frostfs.info/TrueCloudLab/zapjournald v0.0.0-20240124114243-cb2e66427d02
|
git.frostfs.info/TrueCloudLab/zapjournald v0.0.0-20240124114243-cb2e66427d02
|
||||||
github.com/cheggaaa/pb v1.0.29
|
github.com/cheggaaa/pb v1.0.29
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -100,7 +100,7 @@ func (cs *boltLocalOverrideStorage) Close() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTargetBucket(tx *bbolt.Tx, name chain.Name, target policyengine.Target) (*bbolt.Bucket, error) {
|
func getTypeBucket(tx *bbolt.Tx, name chain.Name, target policyengine.Target) (*bbolt.Bucket, error) {
|
||||||
cbucket := tx.Bucket(chainBucket)
|
cbucket := tx.Bucket(chainBucket)
|
||||||
if cbucket == nil {
|
if cbucket == nil {
|
||||||
return nil, ErrRootBucketNotFound
|
return nil, ErrRootBucketNotFound
|
||||||
|
@ -110,16 +110,25 @@ func getTargetBucket(tx *bbolt.Tx, name chain.Name, target policyengine.Target)
|
||||||
if nbucket == nil {
|
if nbucket == nil {
|
||||||
return nil, fmt.Errorf("%w: %w: %s", policyengine.ErrChainNotFound, ErrGlobalNamespaceBucketNotFound, name)
|
return nil, fmt.Errorf("%w: %w: %s", policyengine.ErrChainNotFound, ErrGlobalNamespaceBucketNotFound, name)
|
||||||
}
|
}
|
||||||
|
return nbucket.Bucket([]byte{byte(target.Type)}), nil
|
||||||
|
}
|
||||||
|
|
||||||
typeBucket := nbucket.Bucket([]byte{byte(target.Type)})
|
func normalizeTargetName(target *policyengine.Target) {
|
||||||
|
if target.Type == policyengine.Namespace && target.Name == "" {
|
||||||
|
target.Name = "root"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTargetBucket(tx *bbolt.Tx, name chain.Name, target policyengine.Target) (*bbolt.Bucket, error) {
|
||||||
|
typeBucket, err := getTypeBucket(tx, name, target)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if typeBucket == nil {
|
if typeBucket == nil {
|
||||||
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 == "" {
|
normalizeTargetName(&target)
|
||||||
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)
|
||||||
|
@ -151,10 +160,7 @@ func getTargetBucketCreateIfEmpty(tx *bbolt.Tx, name chain.Name, target policyen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if target.Type == policyengine.Namespace && target.Name == "" {
|
normalizeTargetName(&target)
|
||||||
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
|
||||||
|
@ -220,6 +226,17 @@ func (cs *boltLocalOverrideStorage) RemoveOverride(name chain.Name, target polic
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cs *boltLocalOverrideStorage) RemoveOverridesByTarget(name chain.Name, target policyengine.Target) error {
|
||||||
|
return cs.db.Update(func(tx *bbolt.Tx) error {
|
||||||
|
typeBucket, err := getTypeBucket(tx, name, target)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
normalizeTargetName(&target)
|
||||||
|
return typeBucket.DeleteBucket([]byte(target.Name))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (cs *boltLocalOverrideStorage) ListOverrides(name chain.Name, target policyengine.Target) ([]*chain.Chain, error) {
|
func (cs *boltLocalOverrideStorage) ListOverrides(name chain.Name, target policyengine.Target) ([]*chain.Chain, error) {
|
||||||
var serializedChains [][]byte
|
var serializedChains [][]byte
|
||||||
var serializedChain []byte
|
var serializedChain []byte
|
||||||
|
|
Loading…
Reference in a new issue