identityset

package
v0.0.0-...-35d8de9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

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

Index

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

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

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

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

Union returns a union of a list of sets.

func (*Set) AddGroup

func (s *Set) AddGroup(group string)

AddGroup adds a single group to the set.

The receiver must not be nil.

func (*Set) AddIdentity

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

AddIdentity adds a single identity to the set.

The receiver must not be nil.

func (*Set) IsEmpty

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

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

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

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

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

ToStrings returns a sorted list of strings representing this set.

See 'FromStrings' for the format of this list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL