Documentation ¶
Index ¶
- Constants
- func ConcurrentSync(ctx context.Context, syncer v1alpha3.GroupSyncer, sourceGroupIDs []string) error
- type Error
- type Group
- type GroupMember
- type GroupReadWriter
- type GroupReader
- type GroupWriter
- type ManyToManySyncer
- type Member
- type OneToManyGroupMapper
- type User
- type UserMapper
- type UserMember
Constants ¶
const ErrTargetUserIDNotFound = Error("target user ID not found")
ErrTargetUserIDNotFound denotes when the user ID for the target system cannot be found.
Variables ¶
This section is empty.
Functions ¶
func ConcurrentSync ¶
func ConcurrentSync(ctx context.Context, syncer v1alpha3.GroupSyncer, sourceGroupIDs []string) error
ConcurrentSync syncs the given source groups concurrently using the given syncer. The level of concurrency is based of the value of runtime.NumCPU.
Types ¶
type Group ¶
type Group struct { // ID is the group's ID in the group system. ID string `json:"id,omitempty"` // Attributes represent arbitrary attributes about the group // in the given group system. This field is typically set by // the corresponding GroupReader when retrieving the group. Attributes any `json:"attributes,omitempty"` }
Group represents a group in a group system.
type GroupMember ¶
type GroupMember struct {
Grp *Group
}
GroupMember represents a group membership of a group.
func (*GroupMember) Group ¶
func (g *GroupMember) Group() (*Group, error)
Group returns the underlying group of this Member.
func (*GroupMember) ID ¶
func (g *GroupMember) ID() string
ID is the group's ID in the group system.
func (*GroupMember) IsGroup ¶
func (g *GroupMember) IsGroup() bool
IsGroup returns whether this Member is a Group. Always returns true.
func (*GroupMember) IsUser ¶
func (g *GroupMember) IsUser() bool
IsUser returns whether this Member is a User. Always returns false.
type GroupReadWriter ¶
type GroupReadWriter interface { GroupReader GroupWriter }
GroupReadWriter provides both read and write operations for a group system.
type GroupReader ¶
type GroupReader interface { // Descendants retrieve all users (children, recursively) of a group. Descendants(ctx context.Context, groupID string) ([]*User, error) // GetGroup retrieves the Group with the given ID. GetGroup(ctx context.Context, groupID string) (*Group, error) // GetMembers retrieves the direct members (children) of the group with given ID. GetMembers(ctx context.Context, groupID string) ([]Member, error) // GetUser retrieves the User with the given ID. GetUser(ctx context.Context, userID string) (*User, error) }
GroupReader provides read operations for a group system.
type GroupWriter ¶
type GroupWriter interface { // SetMembers replaces the members of the group with the given ID with the given members. SetMembers(ctx context.Context, groupID string, members []Member) error }
GroupWriter provides write operations for a group system.
type ManyToManySyncer ¶
type ManyToManySyncer struct {
// contains filtered or unexported fields
}
ManyToManySyncer adheres to the v1alpha3.GroupSyncer interface. This syncer allows for syncing many source groups to many target groups. It adheres to the following policy when syncing a source group ID:
- Find all the target groups that the given source group maps to.
- For each of those target groups, it finds all source groups that map to it and forms the union of all descendants from amongst those groups.
- This set of source users is then mapped to their corresponding target users forming the target member set.
- The target member set is then synced to the target group.
func NewManyToManySyncer ¶
func NewManyToManySyncer( sourceSystem, targetSystem string, sourceGroupClient GroupReader, targetGroupClient GroupWriter, sourceGroupMapper OneToManyGroupMapper, targetGroupMapper OneToManyGroupMapper, userMapper UserMapper, ) *ManyToManySyncer
NewManyToManySyncer creates a new ManyToManySyncer.
func (*ManyToManySyncer) SourceSystem ¶
func (f *ManyToManySyncer) SourceSystem() string
SourceSystem returns the name of the source group system.
func (*ManyToManySyncer) Sync ¶
func (f *ManyToManySyncer) Sync(ctx context.Context, sourceGroupID string) error
Sync syncs the source group with the given ID to the target group system.
func (*ManyToManySyncer) SyncAll ¶
func (f *ManyToManySyncer) SyncAll(ctx context.Context) error
SyncAll syncs all source groups that this GroupSyncer is aware of to the target system.
func (*ManyToManySyncer) TargetSystem ¶
func (f *ManyToManySyncer) TargetSystem() string
TargetSystem returns the name of the target group system.
type Member ¶
type Member interface { // ID is the member's ID int the group system. ID() string // IsGroup returns whether this Member is a Group. IsGroup() bool // IsUser returns whether this Member is a User. IsUser() bool // Group returns the underlying group if this Member is a group and never an error. // Otherwise, if this member is a user, then it always returns an error and never a group. // A common pattern is to use IsGroup as a guard before using this method: // // if member.IsGroup() { // group, _ := member.Group() // } Group() (*Group, error) // User returns the underlying user if this Member is a user and never an error. // Otherwise, if this member is a group, then it always returns an error and never a user. // A common pattern is to use IsUser as a guard before using this method: // // if member.IsUser() { // user, _ := member.User() // } User() (*User, error) }
Member represents a member of a group. A member may either be a User or another Group. An instance of Member will always be either a User or a Group but not both.
type OneToManyGroupMapper ¶
type OneToManyGroupMapper interface { // AllGroupIDs returns the set of groupIDs being mapped (the key set). AllGroupIDs(ctx context.Context) ([]string, error) // ContainsGroupID returns whether this mapper contains a mapping for the given group ID. ContainsGroupID(ctx context.Context, groupID string) (bool, error) // MappedGroupIDs returns the list of group IDs mapped to the given group ID. MappedGroupIDs(ctx context.Context, groupID string) ([]string, error) }
OneToManyGroupMapper maps group IDs to lists of group IDs.
type User ¶
type User struct { // ID is the user's ID in the group system. ID string `json:"id,omitempty"` // Attributes represent arbitrary attributes about the user // in the given group system. This field is typically set by // the corresponding GroupReader when retrieving the user. Attributes any `json:"attributes,omitempty"` }
User represents a user in a group system.
func Descendants ¶
func Descendants(ctx context.Context, groupID string, memberFunc func(context.Context, string) ([]Member, error)) ([]*User, error)
Descendants retrieve all users (children, recursively) of the given group ID using the given memberFunc. This function serves mostly as a utility function when implementing ReadGroupClients for when there is no special logic for fetching descendants.
type UserMapper ¶
type UserMapper interface { // MappedUserID returns the user ID mapped to the given user ID. MappedUserID(ctx context.Context, userID string) (string, error) }
UserMapper maps a user ID to another user ID.
type UserMember ¶
type UserMember struct {
Usr *User
}
UserMember represents a user membership of a group.
func (*UserMember) IsGroup ¶
func (u *UserMember) IsGroup() bool
IsGroup returns whether this Member is a Group. Always returns false.
func (*UserMember) IsUser ¶
func (u *UserMember) IsUser() bool
IsUser returns whether this Member is a User. Always returns true.
func (*UserMember) User ¶
func (u *UserMember) User() (*User, error)
User returns the underlying user if this Member.