mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-10 13:08:03 +02:00
update
This commit is contained in:
parent
3e3baa03f4
commit
149b628292
@ -107,15 +107,26 @@ func AddRepPolicy(policy models.RepPolicy) (int64, error) {
|
||||
if err := policy.Marshal(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
now := time.Now()
|
||||
policy.CreationTime = now
|
||||
policy.UpdateTime = now
|
||||
if policy.Enabled == 1 {
|
||||
policy.StartTime = now
|
||||
}
|
||||
policy.Deleted = 0
|
||||
|
||||
return GetOrmer().Insert(&policy)
|
||||
o := GetOrmer()
|
||||
sql := `insert into replication_policy (name, project_id, target_id, enabled, description, cron_str, start_time, creation_time, update_time, filters, replicate_deletion)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
params := []interface{}{}
|
||||
params = append(params, policy.Name, policy.ProjectID, policy.TargetID, policy.Enabled, policy.Description, policy.TriggerInDB)
|
||||
now := time.Now()
|
||||
if policy.Enabled == 1 {
|
||||
params = append(params, now)
|
||||
} else {
|
||||
params = append(params, nil)
|
||||
}
|
||||
params = append(params, now, now, policy.FiltersInDB, policy.ReplicateDeletion)
|
||||
|
||||
result, err := o.Raw(sql, params...).Exec()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result.LastInsertId()
|
||||
}
|
||||
|
||||
// GetRepPolicy ...
|
||||
|
@ -45,7 +45,7 @@ type RepPolicy struct {
|
||||
ProjectID int64 `orm:"column(project_id)" json:"project_id"`
|
||||
ProjectName string `orm:"-" json:"project_name,omitempty"`
|
||||
TargetID int64 `orm:"column(target_id)" json:"target_id"`
|
||||
TargetName string `orm:"-" json:"target_name,omitempty"`
|
||||
TargetName string `json:"target_name,omitempty"`
|
||||
Name string `orm:"column(name)" json:"name"`
|
||||
Enabled int `orm:"column(enabled)" json:"enabled"`
|
||||
Description string `orm:"column(description)" json:"description"`
|
||||
|
Loading…
Reference in New Issue
Block a user