group

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: BSD-3-Clause Imports: 12 Imported by: 49

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SharedInfraGroup *sdk.Group
	DefaultGroup     *sdk.Group
)

SharedInfraGroup is the group used to share infrastructure between projects

View Source
var LoadLinkGroupProjectOptions = struct {
	WithGroups LoadLinkGroupProjectOptionFunc
}{
	WithGroups: loadLinkGroupProjectGroups,
}

LoadLinkGroupProjectOptions provides all options on link group project loads functions.

View Source
var LoadOptions = struct {
	Default          LoadOptionFunc
	WithMembers      LoadOptionFunc
	WithOrganization LoadOptionFunc
}{
	Default:          loadDefault,
	WithMembers:      loadMembers,
	WithOrganization: loadOrganization,
}

LoadOptions provides all options on group loads functions.

Functions

func AddWorkflowGroup

AddWorkflowGroup Add permission on the given workflow for the given group

func CheckGroupPermission added in v0.52.0

func CheckGroupPermission(ctx context.Context, db gorp.SqlExecutor, projectGroups sdk.GroupPermissions, gp *sdk.GroupPermission, consumer *sdk.AuthUserConsumer) error

func CheckGroupPermissionOrganizationMatch added in v0.52.0

func CheckGroupPermissionOrganizationMatch(ctx context.Context, db gorp.SqlExecutor, projectGroups sdk.GroupPermissions, grp *sdk.Group, role int) error

func CheckProjectOrganizationMatch added in v0.52.0

func CheckProjectOrganizationMatch(ctx context.Context, db gorp.SqlExecutor, proj *sdk.Project, grp *sdk.Group, role int) error

func CheckUserInDefaultGroup

func CheckUserInDefaultGroup(ctx context.Context, db gorpmapper.SqlExecutorWithTx, userID string) error

CheckUserInDefaultGroup insert user in default group

func CheckWorkflowGroups added in v0.52.0

func CheckWorkflowGroups(ctx context.Context, db gorp.SqlExecutor, proj *sdk.Project, w *sdk.Workflow, consumer *sdk.AuthUserConsumer) error

func Create

Create insert a new group in database and set user for given id as group admin.

func CreateDefaultGroup

func CreateDefaultGroup(db gorpmapper.SqlExecutorWithTx, groupName string) error

CreateDefaultGroup creates a group 'public' where every user will be

func Delete

func Delete(_ context.Context, db gorp.SqlExecutor, g *sdk.Group) error

Delete deletes group and dependencies.

func DeleteAllGroupFromNode

func DeleteAllGroupFromNode(db gorp.SqlExecutor, nodeID int64) error

DeleteAllGroupFromNode remove all groups from the given node id

func DeleteAllLinksGroupUserForGroupID

func DeleteAllLinksGroupUserForGroupID(db gorp.SqlExecutor, groupID int64) error

DeleteAllLinksGroupUser removes all links group-user into database for given group.

func DeleteLinkGroupProject

func DeleteLinkGroupProject(db gorp.SqlExecutor, l *LinkGroupProject) error

DeleteLinkGroupProject deletes the link between group and project and checks that group was not last with RWX permission.

func DeleteLinkGroupUser

func DeleteLinkGroupUser(db gorp.SqlExecutor, l *LinkGroupUser) error

DeleteLinkGroupUser removes given link group-user into database.

func DeleteLinkGroupUserForGroupIDAndUserID

func DeleteLinkGroupUserForGroupIDAndUserID(db gorp.SqlExecutor, groupID int64, userID string) error

DeleteAllLinksGroupUser removes all links group-user into database for given group.

func DeleteLinksGroupProjectForProjectID

func DeleteLinksGroupProjectForProjectID(db gorp.SqlExecutor, projectID int64) error

DeleteLinksGroupProjectForProjectID removes all links between group and project from database for given project id.

func DeleteWorkflowGroup

func DeleteWorkflowGroup(db gorp.SqlExecutor, w *sdk.Workflow, groupID int64, index int) error

DeleteWorkflowGroup remove group permission on the given workflow

func EnsureOrganization

func EnsureOrganization(ctx context.Context, db gorpmapper.SqlExecutorWithTx, g *sdk.Group) error

EnsureOrganization computes group organization from members list and save it if needed.

func InitializeDefaultGroupName

func InitializeDefaultGroupName(db gorp.SqlExecutor, defaultGrpName string) error

InitializeDefaultGroupName initializes sharedInfraGroup and Default Group

func Insert

Insert given group into database.

func InsertGroupOrganization added in v0.53.0

func InsertGroupOrganization(ctx context.Context, db gorpmapper.SqlExecutorWithTx, o *GroupOrganization) error

func InsertGroupsInNode

func InsertGroupsInNode(db gorp.SqlExecutor, groupPermission []sdk.GroupPermission, nodeID int64) error

InsertGroupsInNode Link the given groups and the given environment

func InsertLinkGroupProject

func InsertLinkGroupProject(ctx context.Context, db gorpmapper.SqlExecutorWithTx, l *LinkGroupProject) error

InsertLinkGroupProject inserts given link group-project into database.

func InsertLinkGroupUser

func InsertLinkGroupUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, l *LinkGroupUser) error

InsertLinkGroupUser inserts given link group-user into database.

func IsConsumerGroupAdmin added in v0.52.0

func IsConsumerGroupAdmin(g *sdk.Group, c *sdk.AuthUserConsumer) bool

For given consumer check that it is group admin, member should be loaded on group and worker should be loaded on consumer if exists

func IsDefaultGroupID

func IsDefaultGroupID(groupID int64) bool

IsDefaultGroupID returns true if groupID is the defaultGroupID

func LoadAll

func LoadAll(ctx context.Context, db gorp.SqlExecutor, opts ...LoadOptionFunc) (sdk.Groups, error)

LoadAll returns all groups from database.

func LoadAllByIDs

func LoadAllByIDs(ctx context.Context, db gorp.SqlExecutor, ids []int64, opts ...LoadOptionFunc) (sdk.Groups, error)

LoadAllByIDs returns all groups from database for given ids.

func LoadAllByUserID

func LoadAllByUserID(ctx context.Context, db gorp.SqlExecutor, userID string, opts ...LoadOptionFunc) (sdk.Groups, error)

LoadAllByUserID returns all groups from database for given user id.

func LoadByID

func LoadByID(ctx context.Context, db gorp.SqlExecutor, id int64, opts ...LoadOptionFunc) (*sdk.Group, error)

LoadByID retrieves group from database by id.

func LoadByName

func LoadByName(ctx context.Context, db gorp.SqlExecutor, name string, opts ...LoadOptionFunc) (*sdk.Group, error)

LoadByName retrieves a group by name from database.

func LoadGroupsByNode

func LoadGroupsByNode(db gorp.SqlExecutor, nodeID []int64) (map[int64][]sdk.GroupPermission, error)

LoadGroupsByNode retrieves all groups related to a node

func LoadGroupsIntoProject

func LoadGroupsIntoProject(ctx context.Context, db gorp.SqlExecutor, proj *sdk.Project) error

LoadGroupsIntoProject retrieves all groups related to project

func LoadRoleGroupInWorkflow

func LoadRoleGroupInWorkflow(db gorp.SqlExecutor, workflowID, groupID int64) (int, error)

LoadRoleGroupInWorkflow load role from group linked to the workflow

func LoadWorkflowGroups

func LoadWorkflowGroups(db gorp.SqlExecutor, workflowID int64) ([]sdk.GroupPermission, error)

LoadWorkflowGroups load groups for a workflow

func LoadWorkflowGroupsByWorkflowIDs

func LoadWorkflowGroupsByWorkflowIDs(ctx context.Context, db gorp.SqlExecutor, workflowIDs []int64) (map[int64][]sdk.GroupPermission, error)

LoadWorkflowGroupsByWorkflowIDs returns a map with key: workflowID and value the slite of groups

func Update

Update given group into database.

func UpdateGroupOrganization added in v0.53.0

func UpdateGroupOrganization(ctx context.Context, db gorpmapper.SqlExecutorWithTx, o *GroupOrganization) error

func UpdateLinkGroupProject

func UpdateLinkGroupProject(db gorpmapper.SqlExecutorWithTx, l *LinkGroupProject) error

UpdateLinkGroupProject updates group role for the given project.

func UpdateLinkGroupUser

func UpdateLinkGroupUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, l *LinkGroupUser) error

UpdateLinkGroupUser updates given link group-user into database.

func UpdateWorkflowGroup

func UpdateWorkflowGroup(ctx context.Context, db gorpmapper.SqlExecutorWithTx, w *sdk.Workflow, gp sdk.GroupPermission) error

UpdateWorkflowGroup update group permission for the given group on the current workflow

func Upsert

func Upsert(ctx context.Context, db gorpmapper.SqlExecutorWithTx, oldGroup, newGroup *sdk.Group) error

Create insert a new group in database and set user for given id as group admin.

func UpsertAllWorkflowGroups

func UpsertAllWorkflowGroups(ctx context.Context, db gorpmapper.SqlExecutorWithTx, w *sdk.Workflow, gps []sdk.GroupPermission) error

UpsertAllWorkflowGroups upsert all groups in a workflow

func UpsertWorkflowGroup

func UpsertWorkflowGroup(db gorp.SqlExecutor, projectID, workflowID int64, gp sdk.GroupPermission) error

UpsertWorkflowGroup upsert a workflow group

Types

type GroupOrganization added in v0.53.0

type GroupOrganization struct {
	ID             string `db:"id"`
	GroupID        int64  `db:"group_id"`
	OrganizationID string `db:"organization_id"`
	gorpmapper.SignedEntity
}

func LoadGroupOrganizationByGroupID added in v0.53.0

func LoadGroupOrganizationByGroupID(ctx context.Context, db gorp.SqlExecutor, groupID int64) (*GroupOrganization, error)

func LoadGroupOrganizationsByGroupIDs added in v0.53.0

func LoadGroupOrganizationsByGroupIDs(ctx context.Context, db gorp.SqlExecutor, groupIDs []int64) ([]GroupOrganization, error)

func (GroupOrganization) Canonical added in v0.53.0

type LinkGroupProject

type LinkGroupProject struct {
	gorpmapper.SignedEntity
	ID        int64 `db:"id"`
	GroupID   int64 `db:"group_id"`
	ProjectID int64 `db:"project_id"`
	Role      int   `db:"role"`
	// Aggregates
	Group sdk.Group `db:"-"`
}

LinkGroupProject struct for database entity of project_group table.

func LoadLinkGroupProjectForGroupIDAndProjectID

func LoadLinkGroupProjectForGroupIDAndProjectID(ctx context.Context, db gorp.SqlExecutor, groupID, projectID int64) (*LinkGroupProject, error)

LoadLinkGroupProjectForGroupIDAndProjectID returns a link from project_group if exists for given group and project ids.

func (LinkGroupProject) Canonical

type LinkGroupUser

type LinkGroupUser struct {
	ID                 int64  `db:"id"`
	GroupID            int64  `db:"group_id"`
	AuthentifiedUserID string `db:"authentified_user_id"`
	Admin              bool   `db:"group_admin"`
	gorpmapper.SignedEntity
}

LinkGroupUser struct for database entity of group_authentified_user table.

func LoadLinkGroupUserForGroupIDAndUserID

func LoadLinkGroupUserForGroupIDAndUserID(ctx context.Context, db gorp.SqlExecutor, groupID int64, userID string) (*LinkGroupUser, error)

LoadLinkGroupUserForGroupIDAndUserID returns a link from group_user if exists for given group and user ids.

func (LinkGroupUser) Canonical

func (c LinkGroupUser) Canonical() gorpmapper.CanonicalForms

type LinkWorkflowGroupPermission

type LinkWorkflowGroupPermission struct {
	WorkflowID int64  `db:"workflow_id"`
	GroupID    int64  `db:"group_id"`
	GroupName  string `db:"group_name"`
	Role       int    `db:"role"`
}

type LinksGroupProject

type LinksGroupProject []LinkGroupProject

LinksGroupProject struct.

func LoadLinksGroupProjectForGroupID

func LoadLinksGroupProjectForGroupID(ctx context.Context, db gorp.SqlExecutor, groupID int64, opts ...LoadLinkGroupProjectOptionFunc) (LinksGroupProject, error)

LoadLinksGroupProjectForGroupID returns data from project_group table for given group id.

func LoadLinksGroupProjectForProjectIDs

func LoadLinksGroupProjectForProjectIDs(ctx context.Context, db gorp.SqlExecutor, projectIDs []int64, opts ...LoadLinkGroupProjectOptionFunc) (LinksGroupProject, error)

LoadLinksGroupProjectForProjectIDs returns data from project_group table for given group id.

func (LinksGroupProject) ToMapByProjectID

func (l LinksGroupProject) ToMapByProjectID() map[int64]LinksGroupProject

ToMapByProjectID groups links by project id in a map.

func (LinksGroupProject) ToProjectIDs

func (l LinksGroupProject) ToProjectIDs() []int64

ToProjectIDs returns project ids for given links.

type LinksGroupUser

type LinksGroupUser []LinkGroupUser

LinksGroupUser struct.

func LoadLinksGroupUserForGroupIDs

func LoadLinksGroupUserForGroupIDs(ctx context.Context, db gorp.SqlExecutor, groupIDs []int64) (LinksGroupUser, error)

LoadLinksGroupUserForGroupIDs returns data from group_user table for given group ids.

func LoadLinksGroupUserForUserIDs

func LoadLinksGroupUserForUserIDs(ctx context.Context, db gorp.SqlExecutor, userIDs []string) (LinksGroupUser, error)

LoadLinksGroupUserForUserIDs returns data from group_user table for given user ids.

func (LinksGroupUser) ToGroupIDs

func (l LinksGroupUser) ToGroupIDs() []int64

ToGroupIDs returns group ids for given links.

func (LinksGroupUser) ToUserIDs

func (l LinksGroupUser) ToUserIDs() []string

ToUserIDs returns user ids for given links.

type LoadLinkGroupProjectOptionFunc

type LoadLinkGroupProjectOptionFunc func(context.Context, gorp.SqlExecutor, ...*LinkGroupProject) error

LoadLinkGroupProjectOptionFunc for link group project.

type LoadOptionFunc

type LoadOptionFunc func(context.Context, gorp.SqlExecutor, ...*sdk.Group) error

LoadOptionFunc for group.

Jump to

Keyboard shortcuts

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