Skip to content

Commit

Permalink
Merge pull request #90 from codefresh-io/CR-proces-non-root-app
Browse files Browse the repository at this point in the history
process non root app
  • Loading branch information
pasha-codefresh authored May 18, 2022
2 parents 2b915fe + 8d0cedc commit 2885cee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.14-cap-CR-11708-send-app-deletion
2.1.15-cap-CR-process-non-root-app
15 changes: 13 additions & 2 deletions server/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math"
"os"
"reflect"
"sort"
"strconv"
Expand Down Expand Up @@ -828,6 +829,15 @@ func (s *Server) Watch(q *application.ApplicationQuery, ws application.Applicati
}
}

func shouldProcessNonRootApp() bool {
value := os.Getenv("PROCESS_NON_ROOT_APP")
result, err := strconv.ParseBool(value)
if err != nil {
return false
}
return result
}

func (s *Server) StartEventSource(es *events.EventSource, stream events.Eventing_StartEventSourceServer) error {
var (
logCtx log.FieldLogger = log.StandardLogger()
Expand Down Expand Up @@ -875,7 +885,7 @@ func (s *Server) StartEventSource(es *events.EventSource, stream events.Eventing
return
}

err := s.streamApplicationEvents(stream.Context(), &a, es, stream, ts)
err := s.streamApplicationEvents(stream.Context(), &a, es, stream, ts, shouldProcessNonRootApp())
if err != nil {
logCtx.WithError(err).Error("failed to stream application events")
return
Expand Down Expand Up @@ -972,6 +982,7 @@ func (s *Server) streamApplicationEvents(
es *events.EventSource,
stream events.Eventing_StartEventSourceServer,
ts string,
processRootApp bool,
) error {
var (
logCtx = log.WithField("application", a.Name)
Expand All @@ -985,7 +996,7 @@ func (s *Server) streamApplicationEvents(
isChildApp = a.Labels["app.kubernetes.io/instance"] != ""
}

if !isChildApp {
if !isChildApp || processRootApp {
// application events for child apps would be sent by its parent app
// as resource event
appEvent, err := s.getApplicationEventPayload(ctx, a, es, ts)
Expand Down

0 comments on commit 2885cee

Please sign in to comment.