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: revisions info reporting with multi-sourced apps support #333

Merged
merged 26 commits into from
Oct 5, 2024

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).

@oleksandr-codefresh oleksandr-codefresh force-pushed the CR-23842-revisions-info-reporting branch from 1113941 to 0b50690 Compare September 23, 2024 06:42
@oleksandr-codefresh oleksandr-codefresh force-pushed the CR-23842-revisions-info-reporting branch from 0b50690 to 37f5a05 Compare September 23, 2024 07:36
}
}

if a.Source != nil { // single source app
Copy link
Member

Choose a reason for hiding this comment

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

Can you please just check if app has source and return this source, otherwise execute logic after.

It is impossible that app will not have source at all

// for monorepo support: list with revisions where actual changes to source directory were committed
func GetOperationChangeRevisions(a *appv1.Application) []string {
var revisions []string
if a != nil {
Copy link
Member

Choose a reason for hiding this comment

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

could you please check if app is nil then return empty array, it will not have so much embedded conditions

@@ -46,6 +63,64 @@ func GetOperationRevision(a *appv1.Application) string {
return revision
}

func GetOperationSyncRevisions(a *appv1.Application) []string {
var revisions []string
if a != nil {
Copy link
Member

Choose a reason for hiding this comment

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

same

Revisions: a.Status.OperationState.Operation.Sync.ChangeRevisions,
})
}
} else if a.Operation != nil && a.Operation.Sync != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think we will rid of idea to put it on operation level, we will just persist it on status

Choose a reason for hiding this comment

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

it's just as a fallback so can leave ATM

@oleksandr-codefresh oleksandr-codefresh force-pushed the CR-23842-revisions-info-reporting branch from 17a0ef3 to 893fbcd Compare September 27, 2024 15:20
@oleksandr-codefresh oleksandr-codefresh force-pushed the CR-23842-revisions-info-reporting branch from 893fbcd to 9bc3265 Compare September 27, 2024 15:35

for idx, revision := range revisions {
// report just revision for helm sources
if (a.Spec.HasMultipleSources() && a.Spec.Sources[idx].IsHelm()) || (a.Spec.Source != nil && a.Spec.Source.IsHelm()) {
Copy link
Member

Choose a reason for hiding this comment

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

Please move this condition into dedicated types . Make it a.Spec.IsHelm(idx)

if err == nil && operationSyncRevisionsMetadata != nil {
result.SyncRevisions = operationSyncRevisionsMetadata
}
// latest revision of repository where changes to app resource were actually made; empty if no changeRevisionі present
Copy link
Member

Choose a reason for hiding this comment

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

typo

u = utils.AddCommitDetailsToLabels(u, originalAppRevisionMetadata)
if originalAppRevisionsMetadata != nil {
u = utils.AddCommitsDetailsToAnnotations(u, originalAppRevisionsMetadata)
if originalApplication != nil {
Copy link
Member

Choose a reason for hiding this comment

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

imho it is redundant

Choose a reason for hiding this comment

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

removed

@@ -46,6 +63,70 @@ func GetOperationRevision(a *appv1.Application) string {
return revision
}

func GetOperationSyncRevisions(a *appv1.Application) []string {
var revisions []string
Copy link
Member

Choose a reason for hiding this comment

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

this is redundant variable, you can remove it

@oleksandr-codefresh oleksandr-codefresh force-pushed the CR-23842-revisions-info-reporting branch from c3aa11f to 09fddac Compare October 1, 2024 09:13
@oleksandr-codefresh oleksandr-codefresh merged commit 66e1e38 into release-2.12 Oct 5, 2024
13 checks passed
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