object: Add UserAttributes method #272

Merged
dstepanov-yadro merged 1 commit from a-savchuk/frostfs-sdk-go:object-user-attrs into master 2024-11-02 14:21:46 +00:00
3 changed files with 4 additions and 12 deletions

View file

@ -356,8 +356,7 @@ func (x Container) IterateUserAttributes(f func(key, val string)) {
attrs := x.v2.GetAttributes() attrs := x.v2.GetAttributes()
for _, attr := range attrs { for _, attr := range attrs {
key := attr.GetKey() key := attr.GetKey()
if !strings.HasPrefix(key, container.SysAttributePrefix) && if !strings.HasPrefix(key, container.SysAttributePrefix) {
!strings.HasPrefix(key, container.SysAttributePrefixNeoFS) {
f(key, attr.GetValue()) f(key, attr.GetValue())
} }
} }
@ -417,8 +416,7 @@ func DisableHomomorphicHashing(cnr *Container) {
// //
// Zero Container has enabled hashing. // Zero Container has enabled hashing.
func IsHomomorphicHashingDisabled(cnr Container) bool { func IsHomomorphicHashingDisabled(cnr Container) bool {
return cnr.Attribute(container.SysAttributeHomomorphicHashing) == attributeHomoHashEnabled || return cnr.Attribute(container.SysAttributeHomomorphicHashing) == attributeHomoHashEnabled
cnr.Attribute(container.SysAttributeHomomorphicHashingNeoFS) == attributeHomoHashEnabled
} }
// Domain represents information about container domain registered in the NNS // Domain represents information about container domain registered in the NNS
@ -467,9 +465,6 @@ func ReadDomain(cnr Container) (res Domain) {
if name := cnr.Attribute(container.SysAttributeName); name != "" { if name := cnr.Attribute(container.SysAttributeName); name != "" {
res.SetName(name) res.SetName(name)
res.SetZone(cnr.Attribute(container.SysAttributeZone)) res.SetZone(cnr.Attribute(container.SysAttributeZone))
} else if name = cnr.Attribute(container.SysAttributeNameNeoFS); name != "" {
res.SetName(name)
res.SetZone(cnr.Attribute(container.SysAttributeZoneNeoFS))
} }
return return

View file

@ -150,7 +150,7 @@ func assertContainsAttribute(t *testing.T, m v2container.Container, key, val str
} }
func TestContainer_Attribute(t *testing.T) { func TestContainer_Attribute(t *testing.T) {
const attrKey1, attrKey2 = v2container.SysAttributePrefix + "key1", v2container.SysAttributePrefixNeoFS + "key2" const attrKey1, attrKey2 = v2container.SysAttributePrefix + "key1", v2container.SysAttributePrefix + "key2"
const attrVal1, attrVal2 = "val1", "val2" const attrVal1, attrVal2 = "val1", "val2"
val := containertest.Container() val := containertest.Container()

View file

@ -324,10 +324,7 @@ func (o *Object) UserAttributes() []Attribute {
res := make([]Attribute, 0, len(attrs)) res := make([]Attribute, 0, len(attrs))
for _, attr := range attrs { for _, attr := range attrs {
key := attr.GetKey() if !strings.HasPrefix(attr.GetKey(), container.SysAttributePrefix) {
if !strings.HasPrefix(key, container.SysAttributePrefix) &&
!strings.HasPrefix(key, container.SysAttributePrefixNeoFS) {
res = append(res, *NewAttributeFromV2(&attr)) res = append(res, *NewAttributeFromV2(&attr))
} }
} }

You dropped NeoFS attribute handling here: TrueCloudLab/frostfs-node#1379/files

So I think you can drop it from frostfs-sdk too.

You dropped `NeoFS` attribute handling here: https://git.frostfs.info/TrueCloudLab/frostfs-node/pulls/1379/files So I think you can drop it from frostfs-sdk too.

Done

Done