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:
Wang Yan 2021-01-22 18:50:16 +08:00 committed by GitHub
parent b2fe254974
commit 8e7a18dc80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()