Documentation ¶
Overview ¶
Package reconciler reconciles the events
Index ¶
- Variables
- type Option
- func WithApplicationType(t string) Option
- func WithAuditEventWriter(a *auditevent.EventWriter) Option
- func WithClient(c *slack.Client) Option
- func WithDryRun(d bool) Option
- func WithGovernorClient(c *governor.Client) Option
- func WithInterval(i time.Duration) Option
- func WithLocker(l *natslock.Locker) Option
- func WithLogger(l *zap.Logger) Option
- func WithQueue(q string) Option
- func WithUserGroupPrefix(p string) Option
- type Reconciler
- func (r *Reconciler) AddUserGroupMember(ctx context.Context, groupID, userID string) error
- func (r *Reconciler) CreateUserGroup(ctx context.Context, groupID, appID string) error
- func (r *Reconciler) DeleteUserGroup(ctx context.Context, groupID, appID string) error
- func (r *Reconciler) RemoveUserGroupMember(ctx context.Context, groupID, userID string) error
- func (r *Reconciler) Run(ctx context.Context)
- func (r *Reconciler) Stop()
- func (r *Reconciler) UpdateUserGroupMembers(ctx context.Context, groupID, appID string) error
- type UserGroup
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadParameter is returned when bad parameters are passed to a request ErrBadParameter = errors.New("bad parameters in request") // ErrRequestNonSuccess is returned when a call to the slack API returns a non-success status ErrRequestNonSuccess = errors.New("got a non-success response from slack") // ErrAppNameEmpty is returned when the governor application name is empty ErrAppNameEmpty = errors.New("governor application name is empty") // ErrGovernorUserPendingStatus is returned when an event it received for a user with pending status ErrGovernorUserPendingStatus = errors.New("governor user has pending status") // ErrGroupMembershipNotFound is returned when a group membership action // is requested and the user is not found in the group ErrGroupMembershipNotFound = errors.New("user not found in group") // ErrGroupMembershipFound is returned when a group membership delete request finds the // user in the governor group ErrGroupMembershipFound = errors.New("delete request user found in group") // ErrSlackUserGroupNotFound is returned when the slack user group is not found ErrSlackUserGroupNotFound = errors.New("slack user group not found") // ErrSlackWorkspaceNotFound is returned when the slack workspace (team) is not found ErrSlackWorkspaceNotFound = errors.New("slack workspace not found") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(r *Reconciler)
Option is a functional configuration option
func WithApplicationType ¶
WithApplicationType sets the application type slug
func WithAuditEventWriter ¶
func WithAuditEventWriter(a *auditevent.EventWriter) Option
WithAuditEventWriter sets auditEventWriter
func WithGovernorClient ¶
WithGovernorClient sets governor api client
func WithInterval ¶
WithInterval sets the reconciler interval
func WithLocker ¶
WithLocker sets the lead election locker
func WithUserGroupPrefix ¶
WithUserGroupPrefix sets a prefix for user group names
type Reconciler ¶
type Reconciler struct { Client *slack.Client GovernorClient govClientIface ID uuid.UUID Locker *natslock.Locker Logger *zap.Logger // contains filtered or unexported fields }
Reconciler reconciles with downstream system
func (*Reconciler) AddUserGroupMember ¶
func (r *Reconciler) AddUserGroupMember(ctx context.Context, groupID, userID string) error
AddUserGroupMember adds a user to a user group if they are not already a member
func (*Reconciler) CreateUserGroup ¶
func (r *Reconciler) CreateUserGroup(ctx context.Context, groupID, appID string) error
CreateUserGroup creates a slack user group for the given governor group if it's linked to a slack application
func (*Reconciler) DeleteUserGroup ¶
func (r *Reconciler) DeleteUserGroup(ctx context.Context, groupID, appID string) error
DeleteUserGroup deletes a corresponding slack user group for the given governor group if it's linked to a slack application. Since Slack doesn't support deleting user groups we simulate deletion by disabling and renaming the user group to a timestamped name.
func (*Reconciler) RemoveUserGroupMember ¶
func (r *Reconciler) RemoveUserGroupMember(ctx context.Context, groupID, userID string) error
RemoveUserGroupMember removes a user from a user group. Slack doesn't allow removing the last user in a group, so in that case we'll return an error.
func (*Reconciler) Run ¶
func (r *Reconciler) Run(ctx context.Context)
Run starts the reconciler loop
func (*Reconciler) Stop ¶
func (r *Reconciler) Stop()
Stop stops the reconciler loop and does any necessary cleanup
func (*Reconciler) UpdateUserGroupMembers ¶
func (r *Reconciler) UpdateUserGroupMembers(ctx context.Context, groupID, appID string) error
UpdateUserGroupMembers updates the members of a slack user group to match the members of the governor group