mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-22 16:48:30 +01:00
handle repository deletion event in API
This commit is contained in:
parent
ac17546d38
commit
23b026655c
@ -154,7 +154,15 @@ func (ra *RepositoryAPI) Delete() {
|
||||
ra.CustomAbort(http.StatusInternalServerError, "internal error")
|
||||
}
|
||||
log.Infof("delete tag: %s %s", repoName, t)
|
||||
go TriggerReplicationByRepository(repoName, []string{t}, models.RepOpDelete)
|
||||
}
|
||||
|
||||
go func() {
|
||||
log.Debug("refreshing catalog cache")
|
||||
if err := cache.RefreshCatalogCache(); err != nil {
|
||||
log.Errorf("error occurred while refresh catalog cache: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
type tag struct {
|
||||
|
@ -73,7 +73,7 @@ func (n *NotificationHandler) Post() {
|
||||
log.Errorf("failed to add access log: %v", err)
|
||||
}
|
||||
}()
|
||||
if action == "push" || action == "delete" {
|
||||
if action == "push" {
|
||||
go func() {
|
||||
if err := cache.RefreshCatalogCache(); err != nil {
|
||||
log.Errorf("failed to refresh cache: %v", err)
|
||||
@ -83,8 +83,6 @@ func (n *NotificationHandler) Post() {
|
||||
operation := ""
|
||||
if action == "push" {
|
||||
operation = models.RepOpTransfer
|
||||
} else {
|
||||
operation = models.RepOpDelete
|
||||
}
|
||||
|
||||
go api.TriggerReplicationByRepository(repository, []string{tag}, operation)
|
||||
@ -96,14 +94,6 @@ func filterEvents(notification *models.Notification) ([]*models.Event, error) {
|
||||
events := []*models.Event{}
|
||||
|
||||
for _, event := range notification.Events {
|
||||
|
||||
//delete
|
||||
// TODO add tag field
|
||||
if event.Action == "delete" {
|
||||
events = append(events, &event)
|
||||
continue
|
||||
}
|
||||
|
||||
isManifest, err := regexp.MatchString(manifestPattern, event.Target.MediaType)
|
||||
if err != nil {
|
||||
log.Errorf("failed to match the media type against pattern: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user