feat: [AH-392]: support multiple scanners - gitness changes (#2834)

* feat: [AH-392]: support multiple scanners - review comments
* feat: [AH-392]: support multiple scanners - lint errors
* feat: [AH-392]: support multiple scanners - gitness changes
pull/3576/head
Shivakumar Ningappa 2024-10-18 20:58:44 +00:00 committed by Harness
parent b002a60b02
commit 884d7b3612
3 changed files with 19 additions and 10 deletions

View File

@ -41,7 +41,7 @@ type RegistryRequestBaseInfo struct {
RegistryRef string
RegistryIdentifier string
registryID int64
RegistryID int64
ParentRef string
parentID int64
@ -124,7 +124,7 @@ func (c *APIController) GetRegistryRequestBaseInfo(
baseInfo.RegistryRef = regRef
baseInfo.RegistryIdentifier = regIdentifier
baseInfo.registryID = reg.ID
baseInfo.RegistryID = reg.ID
}
return baseInfo, nil

View File

@ -24,9 +24,10 @@ import (
type PackageType int32
type ArtifactDetails struct {
RegistryID string `json:"registry_id,omitempty"`
ImagePath string `json:"image_path,omitempty"` // format = image:tag
PackageType PackageType `json:"package_type,omitempty"`
RegistryID int64 `json:"registry_id,omitempty"`
RegistryName string `json:"registry_name,omitempty"`
ImagePath string `json:"image_path,omitempty"` // format = image:tag
PackageType PackageType `json:"package_type,omitempty"`
}
// PackageType constants using iota.

View File

@ -222,7 +222,13 @@ func (l *manifestService) dbTagManifest(
}
spacePath, packageType, err := l.getSpacePathAndPackageType(ctx, dbRegistry)
if err == nil {
l.reportEventAsync(ctx, info.RegIdentifier, imageName, tagName, packageType, spacePath)
reg, err := l.registryDao.GetByParentIDAndName(ctx, info.ParentID, info.RegIdentifier)
if err != nil {
log.Ctx(ctx).Err(err).Msgf("Failed to get registry for parent_id=%d, registry_identifier=%s",
info.ParentID, info.RegIdentifier)
return err
}
l.reportEventAsync(ctx, reg.ID, info.RegIdentifier, imageName, tagName, packageType, spacePath)
} else {
log.Ctx(ctx).Err(err).Msg("Failed to find spacePath, not publishing event")
}
@ -316,16 +322,18 @@ func (l *manifestService) getSpacePathAndPackageType(
// Reports event asynchronously.
func (l *manifestService) reportEventAsync(
ctx context.Context,
regID,
regID int64,
regName,
imageName,
tagName string,
packageType event.PackageType,
spacePath string,
) {
go l.reporter.ReportEvent(ctx, &event.ArtifactDetails{
RegistryID: regID,
ImagePath: imageName + ":" + tagName,
PackageType: packageType,
RegistryID: regID,
RegistryName: regName,
ImagePath: imageName + ":" + tagName,
PackageType: packageType,
}, spacePath)
}