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(event-reporter): multi-sourced apps - resource git details reporting #352

Open
wants to merge 29 commits into
base: release-2.12
Choose a base branch
from

Conversation

oleksandr-codefresh
Copy link

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

…EntityParentApp to pass data between methods
…Resource to pass data between methods, created new methods to group logic inside getResourceEventPayload
…onSyncRevisions, destServer, destName, appMultiSourced
…s SourcePositions, Revisions for GetManifests request
…sion for multi-sourced applications based on sync result revisions
…R-23668-multisource-details-reporting

# Conflicts:
#	event_reporter/reporter/application_event_reporter.go
#	event_reporter/reporter/event_payload.go
#	event_reporter/reporter/types.go
…ce index to which this resource belongs. Also updated logic of retrieving correct git commit info based on AppSourceIdx
@@ -126,6 +126,16 @@ func (c *httpApplicationClient) GetManifests(ctx context.Context, in *appclient.
if in.Revision != nil {
params = fmt.Sprintf("%s&revision=%s", params, *in.Revision)
}
if in.SourcePositions != nil && len(in.SourcePositions) > 0 {
for _, sourcePosition := range in.SourcePositions {
params = fmt.Sprintf("%s&sourcePositions=%s", params, sourcePosition)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have linter issues here

event_reporter/controller/controller.go Outdated Show resolved Hide resolved
event_reporter/reporter/application_event_reporter_test.go Outdated Show resolved Hide resolved
event_reporter/reporter/event_payload.go Show resolved Hide resolved

// this value will be used in case if application hasn't resources , like gitsource
revisions := a.Status.Sync.Revisions
if a.Status.OperationState != nil && a.Status.OperationState.Operation.Sync != nil && a.Status.OperationState.Operation.Sync.Revisions != nil && len(a.Status.OperationState.Operation.Sync.Revisions) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets change to if -> return, and tbh i would move these if condition to some function, it is just very hard to read, i would move it to our custom types that we created before

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to separate func

@@ -65,14 +72,38 @@ func GetOperationRevision(a *appv1.Application) string {
return revision
}

func GetOperationStateRevision(a *appv1.Application) *string {
func GetOperationRevisions(a *appv1.Application) []string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also cover with basic test

if a == nil || a.Status.OperationState == nil || a.Status.OperationState.SyncResult == nil {
return nil
}

return &a.Status.OperationState.SyncResult.Revision
}

func GetOperationSyncResultRevisions(a *appv1.Application) *[]string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some basic unit test

@@ -1812,21 +1812,18 @@ var manifestFile = regexp.MustCompile(`^.*\.(yaml|yml|json|jsonnet)$`)

// findManifests looks at all yaml files in a directory and unmarshals them into a list of unstructured objects
func findManifests(logCtx *log.Entry, appPath string, repoRoot string, env *v1alpha1.Env, directory v1alpha1.ApplicationSourceDirectory, enabledManifestGeneration map[string]bool, maxCombinedManifestQuantity resource.Quantity) ([]manifest, error) {
absRepoRoot, err := filepath.Abs(repoRoot)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you changed it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just moved this line below, to have our changes in one place (will simplify new upstream version merging)

@@ -574,6 +574,7 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
manifestInfo.Manifests[i].CompiledManifest = string(data)
}
}
manifests.SourcesManifestsStartingIdx = append(manifests.SourcesManifestsStartingIdx, int32(len(manifests.Manifests)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you need this field? should we push it to OSS ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need it to be able to report correct repo url, etc. for multi-sourced apps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this info is useful for OSS also

@oleksandr-codefresh oleksandr-codefresh force-pushed the CR-23668-multisource-details-reporting branch from 39ee73d to b348e9a Compare November 13, 2024 11:21
@oleksandr-codefresh oleksandr-codefresh force-pushed the CR-23668-multisource-details-reporting branch from 69451f9 to d780165 Compare November 14, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants