mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-15 23:05:57 +01:00
[cherry-pick] fix robot update issue (#17260)
Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
3897471486
commit
30eaf1cc7c
@ -298,17 +298,18 @@ func (rAPI *robotAPI) updateV2Robot(ctx context.Context, params operation.Update
|
||||
return err
|
||||
}
|
||||
|
||||
projectID, err := getProjectID(ctx, params.Robot.Permissions[0].Namespace)
|
||||
if err != nil {
|
||||
if r.Level != robot.LEVELSYSTEM {
|
||||
projectID, err := getProjectID(ctx, params.Robot.Permissions[0].Namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if r.ProjectID != projectID {
|
||||
return errors.BadRequestError(nil).WithMessage("cannot update the project id of robot")
|
||||
}
|
||||
}
|
||||
if err := rAPI.requireAccess(ctx, params.Robot.Level, params.Robot.Permissions[0].Namespace, rbac.ActionUpdate); err != nil {
|
||||
return err
|
||||
}
|
||||
if r.Level != robot.LEVELSYSTEM && r.ProjectID != projectID {
|
||||
return errors.BadRequestError(nil).WithMessage("cannot update the project id of robot")
|
||||
}
|
||||
if err := rAPI.requireAccess(ctx, params.Robot.Level, projectID, rbac.ActionUpdate); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if params.Robot.Level != r.Level || params.Robot.Name != r.Name {
|
||||
return errors.BadRequestError(nil).WithMessage("cannot update the level or name of robot")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user