Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Application versions #243

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.1-cap-CR-app-version
2.8.1-cap-CR-app-version3
3 changes: 2 additions & 1 deletion pkg/version_config_manager/version_config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package version_config_manager

import (
"errors"

log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -78,7 +79,7 @@ func GetVersionConfig() *VersionConfig {

versionConfig, err := versionConfigManager.ObtainConfig()
if err != nil {
log.Printf("ERROR: Failed to obtain config: %v", err)
log.Printf("Failed to obtain config: %v", err)
return nil
}

Expand Down
27 changes: 25 additions & 2 deletions server/application/application_event_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *applicationEventReporter) streamApplicationEvents(
return nil
}

logWithAppStatus(a, logCtx, ts).Info("sending root application event")
logWithAppStatus(a, logCtx, ts).Infof("sending root application event %v", appEvent)
if err := stream.Send(appEvent); err != nil {
return fmt.Errorf("failed to send event for root application %s/%s: %w", a.Namespace, a.Name, err)
}
Expand Down Expand Up @@ -305,7 +305,7 @@ func (s *applicationEventReporter) processResource(

appRes := appv1.Application{}
if isApp(rs) && actualState.Manifest != nil && json.Unmarshal([]byte(*actualState.Manifest), &appRes) == nil {
logWithAppStatus(&appRes, logCtx, ts).Info("streaming resource event")
logWithAppStatus(&appRes, logCtx, ts).Infof("streaming resource event %v", ev)
} else {
logWithResourceStatus(logCtx, rs).Info("streaming resource event")
}
Expand Down Expand Up @@ -612,6 +612,14 @@ func getResourceEventPayload(
Errors: errors,
AppVersions: applicationVersionsEvents,
}
payload.AppVersions.AppVersion = nil
logCtx.Infof("AppVersion before encoding: %v", safeString(payload.AppVersions.AppVersion))
logCtx.Infof(
"AppVersion deps before encoding: %v ||| %v ||| %v",
safeString(payload.AppVersions.Dependencies.Lock),
safeString(payload.AppVersions.Dependencies.Deps),
safeString(payload.AppVersions.Dependencies.Requirements),
)

payloadBytes, err := json.Marshal(&payload)
if err != nil {
Expand Down Expand Up @@ -720,6 +728,14 @@ func (s *applicationEventReporter) getApplicationEventPayload(
AppVersions: applicationVersionsEvents,
}

logCtx.Infof("AppVersion before encoding: %v", safeString(payload.AppVersions.AppVersion))
logCtx.Infof(
"AppVersion deps before encoding: %v ||| %v ||| %v",
safeString(payload.AppVersions.Dependencies.Lock),
safeString(payload.AppVersions.Dependencies.Deps),
safeString(payload.AppVersions.Dependencies.Requirements),
)

payloadBytes, err := json.Marshal(&payload)
if err != nil {
return nil, fmt.Errorf("failed to marshal payload for resource %s/%s: %w", a.Namespace, a.Name, err)
Expand Down Expand Up @@ -799,3 +815,10 @@ func repoAppVersionsToEvent(applicationVersions *apiclient.ApplicationVersions)
}
return applicationVersionsEvents, nil
}

func safeString(s *string) string {
if s == nil {
return "<nil>"
}
return *s
}
Loading