forked from TrueCloudLab/frostfs-s3-gw
[#535] Support public access block operations
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
parent
4f0f2ca7bd
commit
a7ce40d745
23 changed files with 940 additions and 87 deletions
33
api/cache/policy.go
vendored
33
api/cache/policy.go
vendored
|
@ -44,7 +44,7 @@ func NewMorphPolicyCache(config *Config) *MorphPolicyCache {
|
|||
return &MorphPolicyCache{cache: gc, logger: config.Logger}
|
||||
}
|
||||
|
||||
// Get returns a cached object. Returns nil if value is missing.
|
||||
// Get returns cached chains. Returns nil if value is missing.
|
||||
func (o *MorphPolicyCache) Get(key MorphPolicyCacheKey) []*chain.Chain {
|
||||
entry, err := o.cache.Get(key)
|
||||
if err != nil {
|
||||
|
@ -61,12 +61,39 @@ func (o *MorphPolicyCache) Get(key MorphPolicyCacheKey) []*chain.Chain {
|
|||
return result
|
||||
}
|
||||
|
||||
// Put puts an object to cache.
|
||||
// Put puts chains to cache.
|
||||
func (o *MorphPolicyCache) Put(key MorphPolicyCacheKey, list []*chain.Chain) error {
|
||||
return o.cache.Set(key, list)
|
||||
}
|
||||
|
||||
// Delete deletes an object from cache.
|
||||
// Delete deletes chains from cache.
|
||||
func (o *MorphPolicyCache) Delete(key MorphPolicyCacheKey) bool {
|
||||
return o.cache.Remove(key)
|
||||
}
|
||||
|
||||
// GetBucketPolicy returns cached bucket policy. Returns nil if value is missing.
|
||||
func (o *MorphPolicyCache) GetBucketPolicy(name string) []byte {
|
||||
entry, err := o.cache.Get(name)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
result, ok := entry.([]byte)
|
||||
if !ok {
|
||||
o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)),
|
||||
zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath))
|
||||
return nil
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// PutBucketPolicy puts bucket policy to cache.
|
||||
func (o *MorphPolicyCache) PutBucketPolicy(name string, policy []byte) error {
|
||||
return o.cache.Set(name, policy)
|
||||
}
|
||||
|
||||
// DeleteBucketPolicy deletes bucket policy from cache.
|
||||
func (o *MorphPolicyCache) DeleteBucketPolicy(name string) bool {
|
||||
return o.cache.Remove(name)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue