forked from TrueCloudLab/frostfs-node
[#1190] ape: Introduce Groups
util function to retrieve actor's groupIDs
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
46732b61d7
commit
a1f7615b7e
1 changed files with 16 additions and 0 deletions
|
@ -34,3 +34,19 @@ func FormFrostfsIDRequestProperties(frostFSIDClient frostfsidcore.SubjectProvide
|
|||
|
||||
return reqProps, nil
|
||||
}
|
||||
|
||||
// Groups return the actor's group ids from frostfsid contract.
|
||||
func Groups(frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) ([]string, error) {
|
||||
subj, err := frostFSIDClient.GetSubjectExtended(pk.GetScriptHash())
|
||||
if err != nil {
|
||||
if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) {
|
||||
return nil, fmt.Errorf("get subject error: %w", err)
|
||||
}
|
||||
return []string{}, nil
|
||||
}
|
||||
groups := make([]string, len(subj.Groups))
|
||||
for i, group := range subj.Groups {
|
||||
groups[i] = strconv.FormatInt(group.ID, 10)
|
||||
}
|
||||
return groups, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue