mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-27 21:59:38 +01:00
Merge pull request #341 from ywk253100/sync_image
bug fix: when no rows found, return nil not error
This commit is contained in:
commit
7393c006c9
@ -103,6 +103,9 @@ func GetRepPolicy(id int64) (*models.RepPolicy, error) {
|
|||||||
var policy models.RepPolicy
|
var policy models.RepPolicy
|
||||||
|
|
||||||
if err := o.Raw(sql, id).QueryRow(&policy); err != nil {
|
if err := o.Raw(sql, id).QueryRow(&policy); err != nil {
|
||||||
|
if err == orm.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +154,9 @@ func GetRepPolicyByName(name string) (*models.RepPolicy, error) {
|
|||||||
var policy models.RepPolicy
|
var policy models.RepPolicy
|
||||||
|
|
||||||
if err := o.Raw(sql, name).QueryRow(&policy); err != nil {
|
if err := o.Raw(sql, name).QueryRow(&policy); err != nil {
|
||||||
|
if err == orm.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -83,6 +84,9 @@ func GetRoleByID(id int) (*models.Role, error) {
|
|||||||
|
|
||||||
var role models.Role
|
var role models.Role
|
||||||
if err := o.Raw(sql, id).QueryRow(&role); err != nil {
|
if err := o.Raw(sql, id).QueryRow(&role); err != nil {
|
||||||
|
if err == orm.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &role, nil
|
return &role, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user