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 RegistryRef string
RegistryIdentifier string RegistryIdentifier string
registryID int64 RegistryID int64
ParentRef string ParentRef string
parentID int64 parentID int64
@ -124,7 +124,7 @@ func (c *APIController) GetRegistryRequestBaseInfo(
baseInfo.RegistryRef = regRef baseInfo.RegistryRef = regRef
baseInfo.RegistryIdentifier = regIdentifier baseInfo.RegistryIdentifier = regIdentifier
baseInfo.registryID = reg.ID baseInfo.RegistryID = reg.ID
} }
return baseInfo, nil return baseInfo, nil

View File

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

View File

@ -222,7 +222,13 @@ func (l *manifestService) dbTagManifest(
} }
spacePath, packageType, err := l.getSpacePathAndPackageType(ctx, dbRegistry) spacePath, packageType, err := l.getSpacePathAndPackageType(ctx, dbRegistry)
if err == nil { 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 { } else {
log.Ctx(ctx).Err(err).Msg("Failed to find spacePath, not publishing event") log.Ctx(ctx).Err(err).Msg("Failed to find spacePath, not publishing event")
} }
@ -316,16 +322,18 @@ func (l *manifestService) getSpacePathAndPackageType(
// Reports event asynchronously. // Reports event asynchronously.
func (l *manifestService) reportEventAsync( func (l *manifestService) reportEventAsync(
ctx context.Context, ctx context.Context,
regID, regID int64,
regName,
imageName, imageName,
tagName string, tagName string,
packageType event.PackageType, packageType event.PackageType,
spacePath string, spacePath string,
) { ) {
go l.reporter.ReportEvent(ctx, &event.ArtifactDetails{ go l.reporter.ReportEvent(ctx, &event.ArtifactDetails{
RegistryID: regID, RegistryID: regID,
ImagePath: imageName + ":" + tagName, RegistryName: regName,
PackageType: packageType, ImagePath: imageName + ":" + tagName,
PackageType: packageType,
}, spacePath) }, spacePath)
} }