mirror of https://github.com/harness/drone.git
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 changespull/3576/head
parent
b002a60b02
commit
884d7b3612
|
@ -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
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue