55 "errors"
66 "fmt"
77 "math"
8+ "os"
89 "reflect"
910 "sort"
1011 "strconv"
@@ -828,6 +829,15 @@ func (s *Server) Watch(q *application.ApplicationQuery, ws application.Applicati
828829 }
829830}
830831
832+ func shouldProcessNonRootApp () bool {
833+ value := os .Getenv ("PROCESS_NON_ROOT_APP" )
834+ result , err := strconv .ParseBool (value )
835+ if err != nil {
836+ return false
837+ }
838+ return result
839+ }
840+
831841func (s * Server ) StartEventSource (es * events.EventSource , stream events.Eventing_StartEventSourceServer ) error {
832842 var (
833843 logCtx log.FieldLogger = log .StandardLogger ()
@@ -875,7 +885,7 @@ func (s *Server) StartEventSource(es *events.EventSource, stream events.Eventing
875885 return
876886 }
877887
878- err := s .streamApplicationEvents (stream .Context (), & a , es , stream , ts )
888+ err := s .streamApplicationEvents (stream .Context (), & a , es , stream , ts , shouldProcessNonRootApp () )
879889 if err != nil {
880890 logCtx .WithError (err ).Error ("failed to stream application events" )
881891 return
@@ -972,6 +982,7 @@ func (s *Server) streamApplicationEvents(
972982 es * events.EventSource ,
973983 stream events.Eventing_StartEventSourceServer ,
974984 ts string ,
985+ processRootApp bool ,
975986) error {
976987 var (
977988 logCtx = log .WithField ("application" , a .Name )
@@ -985,7 +996,7 @@ func (s *Server) streamApplicationEvents(
985996 isChildApp = a .Labels ["app.kubernetes.io/instance" ] != ""
986997 }
987998
988- if ! isChildApp {
999+ if ! isChildApp || processRootApp {
9891000 // application events for child apps would be sent by its parent app
9901001 // as resource event
9911002 appEvent , err := s .getApplicationEventPayload (ctx , a , es , ts )
0 commit comments