diff --git a/src/controller/event/handler/webhook/artifact/retention.go b/src/controller/event/handler/webhook/artifact/retention.go index 551cc8c8f..7f145943d 100644 --- a/src/controller/event/handler/webhook/artifact/retention.go +++ b/src/controller/event/handler/webhook/artifact/retention.go @@ -119,8 +119,8 @@ func (r *RetentionHandler) constructRetentionPayload(ctx context.Context, event Operator: execution.Trigger, EventData: &model.EventData{ Retention: &evtModel.Retention{ - Total: task.Total, - Retained: task.Retained, + Total: event.Total, + Retained: event.Retained, HarborHostname: hostname, ProjectName: event.Deleted[0].Target.Namespace, RetentionPolicyID: execution.PolicyID, @@ -138,8 +138,11 @@ func (r *RetentionHandler) constructRetentionPayload(ctx context.Context, event } if len(target.Tags) != 0 { deletedArtifact.NameAndTag = target.Repository + ":" + target.Tags[0] + } else { + // use digest if no tag + deletedArtifact.NameAndTag = target.Repository + "@" + target.Digest } - payload.EventData.Retention.DeletedArtifact = []*evtModel.ArtifactInfo{deletedArtifact} + payload.EventData.Retention.DeletedArtifact = append(payload.EventData.Retention.DeletedArtifact, deletedArtifact) } for _, v := range md.Rules { diff --git a/src/controller/event/metadata/retention.go b/src/controller/event/metadata/retention.go index 492985146..4343528e4 100644 --- a/src/controller/event/metadata/retention.go +++ b/src/controller/event/metadata/retention.go @@ -25,6 +25,8 @@ func (r *RetentionMetaData) Resolve(evt *event.Event) error { Status: r.Status, Deleted: r.Deleted, TaskID: r.TaskID, + Total: r.Total, + Retained: r.Retained, } evt.Topic = event2.TopicTagRetention diff --git a/src/controller/event/topic.go b/src/controller/event/topic.go index de318b211..b0d2dca6b 100644 --- a/src/controller/event/topic.go +++ b/src/controller/event/topic.go @@ -353,6 +353,8 @@ type RetentionEvent struct { OccurAt time.Time Status string Deleted []*selector.Result + Total int + Retained int } func (r *RetentionEvent) String() string {