mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-30 06:03:45 +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
|
// Valid put request validation
|
||||||
func (rq *RobotReq) Valid(v *validation.Validation) {
|
func (rq *RobotReq) Valid(v *validation.Validation) {
|
||||||
switch rq.Disabled {
|
// ToDo: add validation for access info.
|
||||||
case true, false:
|
|
||||||
default:
|
|
||||||
v.SetError("disabled", "must be in [true, false]")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RobotRep ...
|
// RobotRep ...
|
||||||
|
@ -45,13 +45,13 @@ func (r *RobotAPI) Prepare() {
|
|||||||
|
|
||||||
pid, err := r.GetInt64FromPath(":pid")
|
pid, err := r.GetInt64FromPath(":pid")
|
||||||
if err != nil || pid <= 0 {
|
if err != nil || pid <= 0 {
|
||||||
text := "invalid project ID: "
|
var errMsg string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
text += err.Error()
|
errMsg = "failed to get project ID " + err.Error()
|
||||||
} else {
|
} else {
|
||||||
text += fmt.Sprintf("%d", pid)
|
errMsg = "invalid project ID: " + fmt.Sprintf("%d", pid)
|
||||||
}
|
}
|
||||||
r.HandleBadRequest(text)
|
r.HandleBadRequest(errMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
project, err := r.ProjectMgr.Get(pid)
|
project, err := r.ProjectMgr.Get(pid)
|
||||||
@ -137,7 +137,7 @@ func (r *RobotAPI) List() {
|
|||||||
|
|
||||||
count, err := dao.CountRobot(&query)
|
count, err := dao.CountRobot(&query)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
query.Page, query.Size = r.GetPaginationParams()
|
query.Page, query.Size = r.GetPaginationParams()
|
||||||
|
Loading…
Reference in New Issue
Block a user