mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 20:26:13 +01:00
fix legacy robot edit issue (#15709)
fixes #15690, for the legacy robot, update is denied. Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
7345021800
commit
4e984e8c6e
@ -196,7 +196,7 @@ func (rAPI *robotAPI) UpdateRobot(ctx context.Context, params operation.UpdateRo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !r.Editable {
|
if !r.Editable {
|
||||||
err = rAPI.updateV1Robot(ctx, params, r)
|
err = errors.DeniedError(nil).WithMessage("editing of legacy robot is not allowed")
|
||||||
} else {
|
} else {
|
||||||
err = rAPI.updateV2Robot(ctx, params, r)
|
err = rAPI.updateV2Robot(ctx, params, r)
|
||||||
}
|
}
|
||||||
@ -279,21 +279,6 @@ func (rAPI *robotAPI) validate(d int64, level string, permissions []*models.Robo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// only disable can be updated for v1 robot
|
|
||||||
func (rAPI *robotAPI) updateV1Robot(ctx context.Context, params operation.UpdateRobotParams, r *robot.Robot) error {
|
|
||||||
if err := rAPI.requireAccess(ctx, params.Robot.Level, r.ProjectID, rbac.ActionUpdate); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
r.Disabled = params.Robot.Disable
|
|
||||||
r.Description = params.Robot.Description
|
|
||||||
if err := rAPI.robotCtl.Update(ctx, r, &robot.Option{
|
|
||||||
WithPermission: false,
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rAPI *robotAPI) updateV2Robot(ctx context.Context, params operation.UpdateRobotParams, r *robot.Robot) error {
|
func (rAPI *robotAPI) updateV2Robot(ctx context.Context, params operation.UpdateRobotParams, r *robot.Robot) error {
|
||||||
if err := rAPI.validate(params.Robot.Duration, params.Robot.Level, params.Robot.Permissions); err != nil {
|
if err := rAPI.validate(params.Robot.Duration, params.Robot.Level, params.Robot.Permissions); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user