diff --git a/src/controller/event/handler/webhook/artifact/retention.go b/src/controller/event/handler/webhook/artifact/retention.go index 551cc8c8f5c..7f145943d9f 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 49298514696..4343528e4b4 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 de318b2113c..b0d2dca6b56 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 {