Skip to content

Commit c42708b

Browse files
event-reporter: changes after pr review
1 parent c965145 commit c42708b

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

event_reporter/reporter/application_event_reporter.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,12 @@ func (s *applicationEventReporter) StreamApplicationEvents(
224224

225225
func (s *applicationEventReporter) resolveApplicationVersions(ctx context.Context, a *appv1.Application, logCtx *log.Entry) *apiclient.ApplicationVersions {
226226
syncRevision := utils.GetOperationStateRevision(a)
227-
var applicationVersions *apiclient.ApplicationVersions
228-
if syncRevision != nil {
229-
syncManifests, _ := s.getDesiredManifests(ctx, a, syncRevision, logCtx)
230-
applicationVersions = syncManifests.GetApplicationVersions()
231-
} else {
232-
applicationVersions = nil
227+
if syncRevision == nil {
228+
return &apiclient.ApplicationVersions{}
233229
}
234230

235-
return applicationVersions
231+
syncManifests, _ := s.getDesiredManifests(ctx, a, syncRevision, logCtx)
232+
return syncManifests.GetApplicationVersions()
236233
}
237234

238235
func (s *applicationEventReporter) getAppForResourceReporting(

event_reporter/reporter/event_payload.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,8 @@ func buildEventObjectAsLiveAndCompiledManifestsEmpty(
201201
) ([]byte, error) {
202202
// no actual or desired state, don't send event
203203
u := &unstructured.Unstructured{}
204-
apiVersion := rr.rs.Version
205-
if rr.rs.Group != "" {
206-
apiVersion = rr.rs.Group + "/" + rr.rs.Version
207-
}
208204

209-
u.SetAPIVersion(apiVersion)
205+
u.SetAPIVersion(rr.GetApiVersion())
210206
u.SetKind(rr.rs.Kind)
211207
u.SetName(rr.rs.Name)
212208
u.SetNamespace(rr.rs.Namespace)

event_reporter/reporter/types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ type ArgoTrackingMetadata struct {
3131
AppInstanceLabelKey *string
3232
TrackingMethod *appv1.TrackingMethod
3333
}
34+
35+
func (rr *ReportedResource) GetApiVersion() string {
36+
apiVersion := rr.rs.Version
37+
if rr.rs.Group != "" {
38+
apiVersion = rr.rs.Group + "/" + rr.rs.Version
39+
}
40+
41+
return apiVersion
42+
}

0 commit comments

Comments
 (0)