mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
fix robot v1 api update issue (#14050)
For the v1 api, it will not update the description of a robot account. Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
b2fe254974
commit
8e7a18dc80
@ -12,7 +12,6 @@ import (
|
||||
"github.com/goharbor/harbor/src/common/rbac"
|
||||
"github.com/goharbor/harbor/src/controller/project"
|
||||
"github.com/goharbor/harbor/src/controller/robot"
|
||||
"github.com/goharbor/harbor/src/core/config"
|
||||
"github.com/goharbor/harbor/src/lib"
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
@ -224,20 +223,10 @@ func (rAPI *robotV1API) UpdateRobotV1(ctx context.Context, params operation.Upda
|
||||
}
|
||||
robot := r[0]
|
||||
|
||||
// for v1 API, only update the disable and description.
|
||||
if robot.Disabled != params.Robot.Disable {
|
||||
robot.Robot.Disabled = params.Robot.Disable
|
||||
robot.Name = strings.TrimPrefix(params.Robot.Name, config.RobotPrefix())
|
||||
if err := rAPI.robotMgr.Update(ctx, &robot.Robot); err != nil {
|
||||
return rAPI.SendError(ctx, err)
|
||||
}
|
||||
}
|
||||
if robot.Description != params.Robot.Description {
|
||||
robot.Robot.Description = params.Robot.Description
|
||||
robot.Name = strings.TrimPrefix(params.Robot.Name, config.RobotPrefix())
|
||||
if err := rAPI.robotMgr.Update(ctx, &robot.Robot); err != nil {
|
||||
return rAPI.SendError(ctx, err)
|
||||
}
|
||||
// for v1 API, only update the disable.
|
||||
robot.Disabled = params.Robot.Disable
|
||||
if err := rAPI.robotCtl.Update(ctx, robot, nil); err != nil {
|
||||
return rAPI.SendError(ctx, err)
|
||||
}
|
||||
|
||||
return operation.NewUpdateRobotV1OK()
|
||||
|
Loading…
Reference in New Issue
Block a user