Skip to content

Commit

Permalink
event-reporter: refactored fields inside ObjectSource
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-codefresh committed Nov 18, 2024
1 parent ac2eafd commit 06395af
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 117 deletions.
4 changes: 2 additions & 2 deletions event_reporter/reporter/event_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func getResourceEventPayload(
GitManifest: rr.desiredState.RawManifest,
Path: rr.desiredState.Path,
Revision: utils.GetApplicationLatestRevision(reportedEntityParentApp.app),
Revisions: utils.GetApplicationLatestRevisions(reportedEntityParentApp.app),
OperationSyncRevision: utils.GetOperationRevision(reportedEntityParentApp.app),
OperationSyncRevisions: utils.GetOperationRevisions(reportedEntityParentApp.app),
HistoryId: utils.GetLatestAppHistoryId(reportedEntityParentApp.app),
Expand All @@ -126,8 +127,7 @@ func getResourceEventPayload(
addResourceEventPayloadGitCommitDetails(&source, rr, reportedEntityParentApp)

if reportedEntityParentApp.validatedDestination != nil {
source.DestName = &reportedEntityParentApp.validatedDestination.Name
source.DestServer = reportedEntityParentApp.validatedDestination.Server
source.ClusterName = &reportedEntityParentApp.validatedDestination.Name
}

if rr.rs.Health != nil {
Expand Down
8 changes: 8 additions & 0 deletions event_reporter/utils/app_revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func GetApplicationLatestRevision(a *appv1.Application) string {
return a.Status.Sync.Revision
}

func GetApplicationLatestRevisions(a *appv1.Application) []string {
if lastHistory := getLatestAppHistoryItem(a); lastHistory != nil {
return lastHistory.Revisions
}

return a.Status.Sync.Revisions
}

func GetOperationRevision(a *appv1.Application) string {
if a == nil {
return ""
Expand Down
Loading

0 comments on commit 06395af

Please sign in to comment.