mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 12:46:03 +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
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
@ -89,16 +87,10 @@ func ListRegistries(query ...*ListRegistryQuery) (int64, []*models.Registry, err
|
||||
}
|
||||
|
||||
// UpdateRegistry updates one registry
|
||||
func UpdateRegistry(registry *models.Registry) error {
|
||||
func UpdateRegistry(registry *models.Registry, props ...string) error {
|
||||
o := dao.GetOrmer()
|
||||
|
||||
sql := `update registry
|
||||
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()
|
||||
|
||||
_, err := o.Update(registry, props...)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,6 @@ func (m *DefaultManager) Add(registry *model.Registry) (int64, error) {
|
||||
|
||||
// Update updates a registry
|
||||
func (m *DefaultManager) Update(registry *model.Registry, props ...string) error {
|
||||
// TODO(ChenDe): Only update the given props
|
||||
|
||||
r, err := toDaoModel(registry)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
r.Status = string(status)
|
||||
err = m.Update(r)
|
||||
err = m.Update(r, "status")
|
||||
if err != nil {
|
||||
log.Warningf("Update health status for '%s' error: %v", r.URL, err)
|
||||
errCount++
|
||||
|
Loading…
Reference in New Issue
Block a user