luci: go.chromium.org/luci/tokenserver/appengine/impl/utils/identityset Index | Files

package identityset

import "go.chromium.org/luci/tokenserver/appengine/impl/utils/identityset"

Package identityset implements a set-like structure for identity.Identity.

Index

Package Files

identityset.go

type Set Uses

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 Uses

func Extend(orig *Set, id identity.Identity) *Set

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 Uses

func FromStrings(str []string, skip func(string) bool) (*Set, error)

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 Union Uses

func Union(sets ...*Set) *Set

Union returns a union of a list of sets.

func (*Set) AddGroup Uses

func (s *Set) AddGroup(group string)

AddGroup adds a single group to the set.

The receiver must not be nil.

func (*Set) AddIdentity Uses

func (s *Set) AddIdentity(id identity.Identity)

AddIdentity adds a single identity to the set.

The receiver must not be nil.

func (*Set) IsEmpty Uses

func (s *Set) IsEmpty() bool

IsEmpty returns true if this set is empty.

'nil' receiver value is valid and represents an empty set.

func (*Set) IsMember Uses

func (s *Set) IsMember(c context.Context, id identity.Identity) (bool, error)

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 Uses

func (s *Set) IsSubset(superset *Set) bool

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 Uses

func (s *Set) IsSuperset(subset *Set) bool

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.

func (*Set) ToStrings Uses

func (s *Set) ToStrings() []string

ToStrings returns a sorted list of strings representing this set.

See 'FromStrings' for the format of this list.

Package identityset imports 6 packages (graph) and is imported by 4 packages. Updated 2018-08-21. Refresh now. Tools for package owners.