From 4ad86b300a770c079d5285bcd1698656672103d6 Mon Sep 17 00:00:00 2001 From: "stonezdj(Daojun Zhang)" Date: Mon, 12 Aug 2024 11:16:21 +0800 Subject: [PATCH] Check create when fire the artifact event (#20832) fixes #20828 Signed-off-by: stonezdj Co-authored-by: Shengwen YU --- src/controller/artifact/controller.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/controller/artifact/controller.go b/src/controller/artifact/controller.go index 0a2888262..4bcea401f 100644 --- a/src/controller/artifact/controller.go +++ b/src/controller/artifact/controller.go @@ -173,16 +173,18 @@ func (c *controller) Ensure(ctx context.Context, repository, digest string, opti } } } - // fire event - e := &metadata.PushArtifactEventMetadata{ - Ctx: ctx, - Artifact: artifact, - } + if created { + // fire event for create + e := &metadata.PushArtifactEventMetadata{ + Ctx: ctx, + Artifact: artifact, + } - if option != nil && len(option.Tags) > 0 { - e.Tag = option.Tags[0] + if option != nil && len(option.Tags) > 0 { + e.Tag = option.Tags[0] + } + notification.AddEvent(ctx, e) } - notification.AddEvent(ctx, e) return created, artifact.ID, nil }