mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-03 15:43:39 +01:00
Merge pull request #7322 from cd1989/update-with-props
Update only specific props in registry update
This commit is contained in:
commit
7fcc391fed
@ -1,8 +1,6 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
|
||||||
"github.com/goharbor/harbor/src/common/dao"
|
"github.com/goharbor/harbor/src/common/dao"
|
||||||
@ -89,16 +87,10 @@ func ListRegistries(query ...*ListRegistryQuery) (int64, []*models.Registry, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRegistry updates one registry
|
// UpdateRegistry updates one registry
|
||||||
func UpdateRegistry(registry *models.Registry) error {
|
func UpdateRegistry(registry *models.Registry, props ...string) error {
|
||||||
o := dao.GetOrmer()
|
o := dao.GetOrmer()
|
||||||
|
|
||||||
sql := `update registry
|
_, err := o.Update(registry, props...)
|
||||||
set url = ?, name = ?, credential_type = ?, access_key = ?, access_secret = ?, type = ?, insecure = ?, health = ?, description = ?, update_time = ?
|
|
||||||
where id = ?`
|
|
||||||
|
|
||||||
_, err := o.Raw(sql, registry.URL, registry.Name, registry.CredentialType, registry.AccessKey, registry.AccessSecret,
|
|
||||||
registry.Type, registry.Insecure, registry.Health, registry.Description, time.Now(), registry.ID).Exec()
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +136,6 @@ func (m *DefaultManager) Add(registry *model.Registry) (int64, error) {
|
|||||||
|
|
||||||
// Update updates a registry
|
// Update updates a registry
|
||||||
func (m *DefaultManager) Update(registry *model.Registry, props ...string) error {
|
func (m *DefaultManager) Update(registry *model.Registry, props ...string) error {
|
||||||
// TODO(ChenDe): Only update the given props
|
|
||||||
|
|
||||||
r, err := toDaoModel(registry)
|
r, err := toDaoModel(registry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Convert registry model to dao layer model error: %v", err)
|
log.Errorf("Convert registry model to dao layer model error: %v", err)
|
||||||
@ -172,7 +170,7 @@ func (m *DefaultManager) HealthCheck() error {
|
|||||||
log.Warningf("Check health status for %s error: %v", r.URL, err)
|
log.Warningf("Check health status for %s error: %v", r.URL, err)
|
||||||
}
|
}
|
||||||
r.Status = string(status)
|
r.Status = string(status)
|
||||||
err = m.Update(r)
|
err = m.Update(r, "status")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("Update health status for '%s' error: %v", r.URL, err)
|
log.Warningf("Update health status for '%s' error: %v", r.URL, err)
|
||||||
errCount++
|
errCount++
|
||||||
|
Loading…
Reference in New Issue
Block a user