Skip to content

Commit

Permalink
use proper revision source
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-codefresh committed Oct 9, 2024
1 parent b9863b1 commit 8044204
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions event_reporter/reporter/application_event_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *applicationEventReporter) shouldSendResourceEvent(a *appv1.Application,
return true
}

func (r *applicationEventReporter) getApplicationManifests(ctx context.Context, a *appv1.Application, revision *string, logCtx *log.Entry) (*apiclient.ManifestResponse, bool) {
func (r *applicationEventReporter) getDesiredManifests(ctx context.Context, a *appv1.Application, revision *string, logCtx *log.Entry) (*apiclient.ManifestResponse, bool) {
// get the desired state manifests of the application
project := a.Spec.GetProject()
desiredManifests, err := r.applicationServiceClient.GetManifests(ctx, &application.ApplicationManifestQuery{
Expand Down Expand Up @@ -138,10 +138,10 @@ func (s *applicationEventReporter) StreamApplicationEvents(

logCtx.Info("getting desired manifests")

desiredManifests, manifestGenErr := s.getApplicationManifests(ctx, a, nil, logCtx)
desiredManifests, manifestGenErr := s.getDesiredManifests(ctx, a, nil, logCtx)

liveManifests, _ := s.getApplicationManifests(ctx, a, &a.Status.Sync.Revision, logCtx)
applicationVersions := liveManifests.GetApplicationVersions()
syncManifests, _ := s.getDesiredManifests(ctx, a, utils.GetOperationStateRevision(a), logCtx)
applicationVersions := syncManifests.GetApplicationVersions()

logCtx.Info("getting parent application name")

Expand All @@ -159,7 +159,7 @@ func (s *applicationEventReporter) StreamApplicationEvents(

rs := utils.GetAppAsResource(a)

parentDesiredManifests, manifestGenErr := s.getApplicationManifests(ctx, parentApplicationEntity, nil, logCtx)
parentDesiredManifests, manifestGenErr := s.getDesiredManifests(ctx, parentApplicationEntity, nil, logCtx)

// helm app hasnt revision
// TODO: add check if it helm application
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 @@ -65,6 +65,14 @@ func GetOperationRevision(a *appv1.Application) string {
return revision
}

func GetOperationStateRevision(a *appv1.Application) *string {
if a == nil || a.Status.OperationState == nil || a.Status.OperationState.SyncResult == nil {
return nil
}

return &a.Status.OperationState.SyncResult.Revision
}

func GetOperationSyncRevisions(a *appv1.Application) []string {
if a == nil {
return []string{}
Expand Down

0 comments on commit 8044204

Please sign in to comment.