mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +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,
|
Operator: execution.Trigger,
|
||||||
EventData: &model.EventData{
|
EventData: &model.EventData{
|
||||||
Retention: &evtModel.Retention{
|
Retention: &evtModel.Retention{
|
||||||
Total: task.Total,
|
Total: event.Total,
|
||||||
Retained: task.Retained,
|
Retained: event.Retained,
|
||||||
HarborHostname: hostname,
|
HarborHostname: hostname,
|
||||||
ProjectName: event.Deleted[0].Target.Namespace,
|
ProjectName: event.Deleted[0].Target.Namespace,
|
||||||
RetentionPolicyID: execution.PolicyID,
|
RetentionPolicyID: execution.PolicyID,
|
||||||
@ -138,8 +138,11 @@ func (r *RetentionHandler) constructRetentionPayload(ctx context.Context, event
|
|||||||
}
|
}
|
||||||
if len(target.Tags) != 0 {
|
if len(target.Tags) != 0 {
|
||||||
deletedArtifact.NameAndTag = target.Repository + ":" + 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 {
|
for _, v := range md.Rules {
|
||||||
|
@ -25,6 +25,8 @@ func (r *RetentionMetaData) Resolve(evt *event.Event) error {
|
|||||||
Status: r.Status,
|
Status: r.Status,
|
||||||
Deleted: r.Deleted,
|
Deleted: r.Deleted,
|
||||||
TaskID: r.TaskID,
|
TaskID: r.TaskID,
|
||||||
|
Total: r.Total,
|
||||||
|
Retained: r.Retained,
|
||||||
}
|
}
|
||||||
|
|
||||||
evt.Topic = event2.TopicTagRetention
|
evt.Topic = event2.TopicTagRetention
|
||||||
|
@ -353,6 +353,8 @@ type RetentionEvent struct {
|
|||||||
OccurAt time.Time
|
OccurAt time.Time
|
||||||
Status string
|
Status string
|
||||||
Deleted []*selector.Result
|
Deleted []*selector.Result
|
||||||
|
Total int
|
||||||
|
Retained int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RetentionEvent) String() string {
|
func (r *RetentionEvent) String() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user