Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine the interface for project rbac #3556

Merged
merged 2 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 92 additions & 34 deletions pkg/datastore/datastoretest/datastore.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 34 additions & 10 deletions pkg/datastore/projectstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ type ProjectStore interface {
DisableStaticAdmin(ctx context.Context, id string) error
UpdateProjectSSOConfig(ctx context.Context, id string, sso *model.ProjectSSOConfig) error
UpdateProjectRBACConfig(ctx context.Context, id string, rbac *model.ProjectRBACConfig) error
UpdateProjectRBACRoles(ctx context.Context, id string, roles []*model.ProjectRBACRole) error
UpdateProjectUserGroups(ctx context.Context, id string, groups []*model.ProjectUserGroup) error
MigrateFromProjectRBACConfig(ctx context.Context, id string) error
GetAllProjectRBACRoles(ctx context.Context, id string) ([]*model.ProjectRBACRole, error)
AddProjectRBACRole(ctx context.Context, id, name string, policies []*model.ProjectRBACPolicy) error
UpdateProjectRBACRole(ctx context.Context, id, name string, policies []*model.ProjectRBACPolicy) error
DeleteProjectRBACRole(ctx context.Context, id, name string) error
GetAllProjectUserGroups(ctx context.Context, id string) ([]*model.ProjectUserGroup, error)
AddProjectUserGroup(ctx context.Context, id, sso, role string) error
DeleteProjectUserGroup(ctx context.Context, id, sso string) error
}

type projectStore struct {
Expand Down Expand Up @@ -199,17 +203,37 @@ func (s *projectStore) UpdateProjectRBACConfig(ctx context.Context, id string, r
})
}

// UpdateProjectRBACRoles updates project rbac roles.
func (s *projectStore) UpdateProjectRBACRoles(ctx context.Context, id string, roles []*model.ProjectRBACRole) error {
return ErrUnimplemented
// GetProjectRBACRoles returns the custom rbacs roles and built-in rbac roles.
func (s *projectStore) GetAllProjectRBACRoles(_ context.Context, _ string) ([]*model.ProjectRBACRole, error) {
return nil, ErrUnimplemented
}

// UpdateProjectUserGroups updates project user groups.
func (s *projectStore) UpdateProjectUserGroups(ctx context.Context, id string, groups []*model.ProjectUserGroup) error {
// AddProjectRBACRole adds the custom rbac role.
func (s *projectStore) AddProjectRBACRole(_ context.Context, _, _ string, _ []*model.ProjectRBACPolicy) error {
return ErrUnimplemented
}

// MigrateFromProjectRBACConfig migrate from ProjectRBACConfig to ProjectUserGroup.
func (s *projectStore) MigrateFromProjectRBACConfig(ctx context.Context, id string) error {
// UpdateProjectRBACRole updates the custom rbac role.
func (s *projectStore) UpdateProjectRBACRole(_ context.Context, _, _ string, _ []*model.ProjectRBACPolicy) error {
return ErrUnimplemented
}

// DeleteProjectRBACRole deletes the custom rbac role.
func (s *projectStore) DeleteProjectRBACRole(_ context.Context, _, _ string) error {
return ErrUnsupported
}

// GetUserGroups returns the user groups.
func (s *projectStore) GetAllProjectUserGroups(_ context.Context, _ string) ([]*model.ProjectUserGroup, error) {
return nil, ErrUnsupported
}

// AddUserGroup adds the user group.
func (s *projectStore) AddProjectUserGroup(_ context.Context, _, _, _ string) error {
return ErrUnsupported
}

// DeleteUserGroup deletes the user group.
func (s *projectStore) DeleteProjectUserGroup(_ context.Context, _, _ string) error {
return ErrUnsupported
}