[cherry-pick] Check create when fire the artifact event (#20842)

Check create when fire the artifact event

  fixes #20828

Signed-off-by: stonezdj <stone.zhang@broadcom.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2024-08-16 15:52:25 +08:00 committed by GitHub
parent a97373f25b
commit 0a8d259c2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -164,16 +164,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
}