mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 17:47:46 +01:00
Add implement for supporting replicatie the existing images now
This commit is contained in:
parent
b5e7de331e
commit
c4dc95f4f9
@ -60,11 +60,16 @@ func (r *ReplicationAPI) Post() {
|
||||
return
|
||||
}
|
||||
|
||||
if err = notifier.Publish(topic.StartReplicationTopic, notification.StartReplicationNotification{
|
||||
PolicyID: replication.PolicyID,
|
||||
}); err != nil {
|
||||
if err = startReplication(replication.PolicyID); err != nil {
|
||||
r.HandleInternalServerError(fmt.Sprintf("failed to publish replication topic for policy %d: %v", replication.PolicyID, err))
|
||||
return
|
||||
}
|
||||
log.Infof("replication topic for policy %d triggered", replication.PolicyID)
|
||||
log.Infof("replication signal for policy %d sent", replication.PolicyID)
|
||||
}
|
||||
|
||||
func startReplication(policyID int64) error {
|
||||
return notifier.Publish(topic.StartReplicationTopic,
|
||||
notification.StartReplicationNotification{
|
||||
PolicyID: policyID,
|
||||
})
|
||||
}
|
||||
|
@ -145,7 +145,15 @@ func (pa *RepPolicyAPI) Post() {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO trigger a replication if ReplicateExistingImageNow is true
|
||||
if policy.ReplicateExistingImageNow {
|
||||
go func() {
|
||||
if err = startReplication(id); err != nil {
|
||||
log.Errorf("failed to send replication signal for policy %d: %v", id, err)
|
||||
return
|
||||
}
|
||||
log.Infof("replication signal for policy %d sent", id)
|
||||
}()
|
||||
}
|
||||
|
||||
pa.Redirect(http.StatusCreated, strconv.FormatInt(id, 10))
|
||||
}
|
||||
@ -201,6 +209,16 @@ func (pa *RepPolicyAPI) Put() {
|
||||
pa.HandleInternalServerError(fmt.Sprintf("failed to update policy %d: %v", id, err))
|
||||
return
|
||||
}
|
||||
|
||||
if policy.ReplicateExistingImageNow {
|
||||
go func() {
|
||||
if err = startReplication(id); err != nil {
|
||||
log.Errorf("failed to send replication signal for policy %d: %v", id, err)
|
||||
return
|
||||
}
|
||||
log.Infof("replication signal for policy %d sent", id)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the replication policy
|
||||
|
Loading…
Reference in New Issue
Block a user