mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 10:15:35 +01:00
fix: correct the retention webhook payload (#18462)
Fix the incorrect number of total and retained in the retention webhook payload, and completes the deleted_artifacts field. Fixes: #18428 Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
parent
1499faf67d
commit
02c51c6b70
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -353,6 +353,8 @@ type RetentionEvent struct {
|
||||
OccurAt time.Time
|
||||
Status string
|
||||
Deleted []*selector.Result
|
||||
Total int
|
||||
Retained int
|
||||
}
|
||||
|
||||
func (r *RetentionEvent) String() string {
|
||||
|
Loading…
Reference in New Issue
Block a user