mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 20:26:13 +01:00
Update validation and error message per comments
This commit is contained in:
parent
4cde11892a
commit
903e15235e
@ -53,11 +53,7 @@ type RobotReq struct {
|
||||
|
||||
// Valid put request validation
|
||||
func (rq *RobotReq) Valid(v *validation.Validation) {
|
||||
switch rq.Disabled {
|
||||
case true, false:
|
||||
default:
|
||||
v.SetError("disabled", "must be in [true, false]")
|
||||
}
|
||||
// ToDo: add validation for access info.
|
||||
}
|
||||
|
||||
// RobotRep ...
|
||||
|
@ -45,13 +45,13 @@ func (r *RobotAPI) Prepare() {
|
||||
|
||||
pid, err := r.GetInt64FromPath(":pid")
|
||||
if err != nil || pid <= 0 {
|
||||
text := "invalid project ID: "
|
||||
var errMsg string
|
||||
if err != nil {
|
||||
text += err.Error()
|
||||
errMsg = "failed to get project ID " + err.Error()
|
||||
} else {
|
||||
text += fmt.Sprintf("%d", pid)
|
||||
errMsg = "invalid project ID: " + fmt.Sprintf("%d", pid)
|
||||
}
|
||||
r.HandleBadRequest(text)
|
||||
r.HandleBadRequest(errMsg)
|
||||
return
|
||||
}
|
||||
project, err := r.ProjectMgr.Get(pid)
|
||||
@ -137,7 +137,7 @@ func (r *RobotAPI) List() {
|
||||
|
||||
count, err := dao.CountRobot(&query)
|
||||
if err != nil {
|
||||
r.HandleInternalServerError(fmt.Sprintf("failed to count robots %v", err))
|
||||
r.HandleInternalServerError(fmt.Sprintf("failed to list robots on project: %d, %v", r.project.ProjectID, err))
|
||||
return
|
||||
}
|
||||
query.Page, query.Size = r.GetPaginationParams()
|
||||
|
Loading…
Reference in New Issue
Block a user