mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
Cleanup some TODO items
This commit is contained in:
@@ -210,7 +210,7 @@ func DeleteXR(ctx context.Context, db bun.IDB, field string, value interface{},
|
||||
func HardDeleteAll(ctx context.Context, db bun.IDB, entity interface{}) error {
|
||||
_, err := db.NewDelete().
|
||||
Model(entity).
|
||||
Where("1 = 1"). // TODO: see how to remove this
|
||||
Where("1 = 1"). // TODO: see how to remove this
|
||||
Exec(ctx)
|
||||
return err
|
||||
}
|
||||
@@ -282,8 +282,7 @@ func ListAll(ctx context.Context, db bun.IDB, entities interface{}) (interface{}
|
||||
return entities, err
|
||||
}
|
||||
|
||||
func GetByTraits(ctx context.Context, db bun.IDB, name string, entity interface{}) (interface{}, error) {
|
||||
// TODO: better name and possibly pass in trait name
|
||||
func GetUserByEmail(ctx context.Context, db bun.IDB, name string, entity interface{}) (interface{}, error) {
|
||||
err := db.NewSelect().Model(entity).
|
||||
Where("traits ->> 'email' = ?", name).
|
||||
Scan(ctx)
|
||||
@@ -294,7 +293,7 @@ func GetByTraits(ctx context.Context, db bun.IDB, name string, entity interface{
|
||||
return entity, nil
|
||||
}
|
||||
|
||||
func GetByTraitsFull(ctx context.Context, db bun.IDB, name string, entity interface{}) (interface{}, error) {
|
||||
func GetUserFullByEmail(ctx context.Context, db bun.IDB, name string, entity interface{}) (interface{}, error) {
|
||||
err := db.NewSelect().Model(entity).
|
||||
Where("traits ->> 'email' = ?", name).
|
||||
Relation("IdentityCredential").
|
||||
@@ -307,8 +306,7 @@ func GetByTraitsFull(ctx context.Context, db bun.IDB, name string, entity interf
|
||||
return entity, nil
|
||||
}
|
||||
|
||||
func GetIdByTraits(ctx context.Context, db bun.IDB, name string, entity interface{}) (interface{}, error) {
|
||||
// TODO: better name and possibly pass in trait name
|
||||
func GetUserIdByEmail(ctx context.Context, db bun.IDB, name string, entity interface{}) (interface{}, error) {
|
||||
err := db.NewSelect().Column("id").Model(entity).
|
||||
Where("traits ->> 'email' = ?", name).
|
||||
Scan(ctx)
|
||||
|
||||
+2
-2
@@ -246,7 +246,7 @@ func GetActorFromSessionData(sd *commonv3.SessionData) *EventActor {
|
||||
account := EventActorAccount{
|
||||
Username: username,
|
||||
}
|
||||
groups := sd.Groups // TODO: get groups (in interceptor?)
|
||||
groups := sd.Groups
|
||||
|
||||
return &EventActor{
|
||||
Type: "USER",
|
||||
@@ -298,7 +298,7 @@ func CreateV1Event(al *zap.Logger, sd *commonv3.SessionData, detail *EventDetail
|
||||
Client: client,
|
||||
Detail: detail,
|
||||
Type: eventType,
|
||||
Portal: "OPS", // TODO: What is the portal?
|
||||
Portal: "OPS",
|
||||
Project: project,
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ func (s *groupService) createGroupAccountRelations(ctx context.Context, db bun.I
|
||||
var uids []uuid.UUID
|
||||
for _, account := range utils.Unique(group.GetSpec().GetUsers()) {
|
||||
// FIXME: do combined lookup
|
||||
entity, err := dao.GetIdByTraits(ctx, db, account, &models.KratosIdentities{})
|
||||
entity, err := dao.GetUserIdByEmail(ctx, db, account, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
return &userv3.Group{}, nil, fmt.Errorf("unable to find user '%v'", account)
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ func (s *projectService) List(ctx context.Context, project *systemv3.Project) (*
|
||||
|
||||
var projs []models.Project
|
||||
if !s.dev {
|
||||
entity, err := dao.GetByTraits(ctx, s.db, username, &models.KratosIdentities{})
|
||||
entity, err := dao.GetUserByEmail(ctx, s.db, username, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
return &systemv3.ProjectList{}, err
|
||||
}
|
||||
@@ -538,7 +538,7 @@ func (s *projectService) createProjectAccountRelations(ctx context.Context, db b
|
||||
|
||||
for _, ur := range project.GetSpec().GetUserRoles() {
|
||||
// FIXME: do combined lookup
|
||||
entity, err := dao.GetIdByTraits(ctx, db, ur.User, &models.KratosIdentities{})
|
||||
entity, err := dao.GetUserIdByEmail(ctx, db, ur.User, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
return &systemv3.Project{}, fmt.Errorf("unable to find user '%v'", ur.User)
|
||||
}
|
||||
|
||||
+4
-4
@@ -503,7 +503,7 @@ func (s *userService) GetByID(ctx context.Context, user *userv3.User) (*userv3.U
|
||||
|
||||
func (s *userService) GetByName(ctx context.Context, user *userv3.User) (*userv3.User, error) {
|
||||
name := user.GetMetadata().GetName()
|
||||
entity, err := dao.GetByTraits(ctx, s.db, name, &models.KratosIdentities{})
|
||||
entity, err := dao.GetUserByEmail(ctx, s.db, name, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
return &userv3.User{}, err
|
||||
}
|
||||
@@ -536,7 +536,7 @@ func (s *userService) GetUserInfo(ctx context.Context, user *userv3.User) (*user
|
||||
}
|
||||
_log.Info("username ", username)
|
||||
|
||||
entity, err := dao.GetByTraits(ctx, s.db, username, &models.KratosIdentities{})
|
||||
entity, err := dao.GetUserByEmail(ctx, s.db, username, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
return &userv3.UserInfo{}, err
|
||||
}
|
||||
@@ -634,7 +634,7 @@ func (s *userService) deleteUserRoleRelations(ctx context.Context, db bun.IDB, u
|
||||
|
||||
func (s *userService) Update(ctx context.Context, user *userv3.User) (*userv3.User, error) {
|
||||
name := user.GetMetadata().GetName()
|
||||
entity, err := dao.GetByTraitsFull(ctx, s.db, name, &models.KratosIdentities{})
|
||||
entity, err := dao.GetUserFullByEmail(ctx, s.db, name, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
return &userv3.User{}, fmt.Errorf("no user found with name '%v'", name)
|
||||
}
|
||||
@@ -706,7 +706,7 @@ func (s *userService) Update(ctx context.Context, user *userv3.User) (*userv3.Us
|
||||
|
||||
func (s *userService) Delete(ctx context.Context, user *userv3.User) (*userrpcv3.DeleteUserResponse, error) {
|
||||
name := user.GetMetadata().GetName()
|
||||
entity, err := dao.GetIdByTraits(ctx, s.db, name, &models.KratosIdentities{})
|
||||
entity, err := dao.GetUserIdByEmail(ctx, s.db, name, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
return &userrpcv3.DeleteUserResponse{}, fmt.Errorf("no user founnd with username '%v'", name)
|
||||
}
|
||||
|
||||
@@ -164,7 +164,6 @@ type AuditLogSearchRequest struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// TODO: this was rafay.dev.common.types.v2.RafayMeta
|
||||
Metadata *v3.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
Filter *AuditLogQueryFilter `protobuf:"bytes,2,opt,name=filter,proto3" json:"filter,omitempty"`
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ message auditLogQueryFilter {
|
||||
}
|
||||
|
||||
message auditLogSearchRequest {
|
||||
// TODO: this was rafay.dev.common.types.v2.RafayMeta
|
||||
rafay.dev.types.common.v3.Metadata metadata = 1;
|
||||
auditLogQueryFilter filter = 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user