Skip to content

Commit

Permalink
event-reporter: changes after pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-codefresh committed Nov 7, 2024
1 parent c965145 commit 5230e16
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
11 changes: 4 additions & 7 deletions event_reporter/reporter/application_event_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,12 @@ func (s *applicationEventReporter) StreamApplicationEvents(

func (s *applicationEventReporter) resolveApplicationVersions(ctx context.Context, a *appv1.Application, logCtx *log.Entry) *apiclient.ApplicationVersions {
syncRevision := utils.GetOperationStateRevision(a)
var applicationVersions *apiclient.ApplicationVersions
if syncRevision != nil {
syncManifests, _ := s.getDesiredManifests(ctx, a, syncRevision, logCtx)
applicationVersions = syncManifests.GetApplicationVersions()
} else {
applicationVersions = nil
if syncRevision == nil {
return nil
}

return applicationVersions
syncManifests, _ := s.getDesiredManifests(ctx, a, syncRevision, logCtx)
return syncManifests.GetApplicationVersions()
}

func (s *applicationEventReporter) getAppForResourceReporting(
Expand Down
6 changes: 1 addition & 5 deletions event_reporter/reporter/event_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,8 @@ func buildEventObjectAsLiveAndCompiledManifestsEmpty(
) ([]byte, error) {
// no actual or desired state, don't send event
u := &unstructured.Unstructured{}
apiVersion := rr.rs.Version
if rr.rs.Group != "" {
apiVersion = rr.rs.Group + "/" + rr.rs.Version
}

u.SetAPIVersion(apiVersion)
u.SetAPIVersion(rr.GetApiVersion())
u.SetKind(rr.rs.Kind)
u.SetName(rr.rs.Name)
u.SetNamespace(rr.rs.Namespace)
Expand Down
9 changes: 9 additions & 0 deletions event_reporter/reporter/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ type ArgoTrackingMetadata struct {
AppInstanceLabelKey *string
TrackingMethod *appv1.TrackingMethod
}

func (rr *ReportedResource) GetApiVersion() string {
apiVersion := rr.rs.Version
if rr.rs.Group != "" {
apiVersion = rr.rs.Group + "/" + rr.rs.Version
}

return apiVersion
}

0 comments on commit 5230e16

Please sign in to comment.