Documentation ¶
Overview ¶
Package identityset implements a set-like structure for identity.Identity.
Index ¶
- type Set
- func (s *Set) AddGroup(group string)
- func (s *Set) AddIdentity(id identity.Identity)
- func (s *Set) IsEmpty() bool
- func (s *Set) IsMember(c context.Context, id identity.Identity) (bool, error)
- func (s *Set) IsSubset(superset *Set) bool
- func (s *Set) IsSuperset(subset *Set) bool
- func (s *Set) ToStrings() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set struct { All bool // if true, this set contains all possible identities IDs identSet // set of identity.Identity strings Groups groupSet // set of group names }
Set is a set of identities represented as sets of IDs and groups.
Groups are generally not expanded, but treated as different kind of items, so essentially this struct represents two sets: a set of explicitly specified identities, and a set of groups. The exception to this rule is IsMember function that looks inside the groups.
func Extend ¶
Extend returns a throw-away set that has one additional member.
The returned set must not be modified, since it references data of the original set (to avoid unnecessary copying).
func FromStrings ¶
FromStrings constructs a Set by parsing a slice of strings.
Each string is either:
- "<kind>:<id>" identity string.
- "group:<name>" group reference.
- "*" token to mean "All identities".
Any string that matches 'skip' predicate is skipped.
func (*Set) AddIdentity ¶
AddIdentity adds a single identity to the set.
The receiver must not be nil.
func (*Set) IsEmpty ¶
IsEmpty returns true if this set is empty.
'nil' receiver value is valid and represents an empty set.
func (*Set) IsMember ¶
IsMember returns true if the given identity is in the set.
It looks inside the groups too.
'nil' receiver value is valid and represents an empty set.
func (*Set) IsSubset ¶
IsSubset returns true if this set if a subset of another set.
Two equal sets are considered subsets of each other.
It doesn't attempt to expand groups. Compares IDs and Groups sets separately, as independent kinds of entities.
'nil' receiver and argument values are valid and represent empty sets.
func (*Set) IsSuperset ¶
IsSuperset returns true if this set is a super set of another set.
Two equal sets are considered supersets of each other.
'nil' receiver and argument values are valid and represent empty sets.