Fix delete repository event issue (#11722)

In the delete repository scenario, the repository has already been removed from the DB, the repository cannot be retrived.
Just let the creation time as empty.

Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
Wang Yan 2020-04-26 16:51:13 +08:00 committed by GitHub
parent c28f6bd6ff
commit 8d5fc4c752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,9 +115,10 @@ func (a *Handler) constructArtifactPayload(event *event.ArtifactEvent) (*model.P
repoRecord, err := repository.Mgr.GetByName(ctx, repoName) repoRecord, err := repository.Mgr.GetByName(ctx, repoName)
if err != nil { if err != nil {
log.Errorf("failed to get repository with name %s: %v", repoName, err) log.Errorf("failed to get repository with name %s: %v", repoName, err)
return nil, err } else {
// for the delete repository event, it cannot get the repo info here, just let the creation time be empty.
payload.EventData.Repository.DateCreated = repoRecord.CreationTime.Unix()
} }
payload.EventData.Repository.DateCreated = repoRecord.CreationTime.Unix()
var reference string var reference string
if len(event.Tags) == 0 { if len(event.Tags) == 0 {