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

fix: fix source ordering issue in manifest generation for multi-source app while using manifests and diff commands (cherry-pick #18395) #18408

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
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
9 changes: 5 additions & 4 deletions server/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,16 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
}

sources := make([]appv1.ApplicationSource, 0)
appSpec := a.Spec.DeepCopy()
if a.Spec.HasMultipleSources() {
numOfSources := int64(len(a.Spec.GetSources()))
for i, pos := range q.SourcePositions {
if pos <= 0 || pos > numOfSources {
return fmt.Errorf("source position is out of range")
}
a.Spec.Sources[pos-1].TargetRevision = q.Revisions[i]
appSpec.Sources[pos-1].TargetRevision = q.Revisions[i]
}
sources = a.Spec.GetSources()
sources = appSpec.GetSources()
} else {
source := a.Spec.GetSource()
if q.GetRevision() != "" {
Expand All @@ -487,7 +488,7 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
}

// Store the map of all sources having ref field into a map for applications with sources field
refSources, err := argo.GetRefSources(context.Background(), a.Spec, s.db)
refSources, err := argo.GetRefSources(context.Background(), *appSpec, s.db)
if err != nil {
return fmt.Errorf("failed to get ref sources: %v", err)
}
Expand Down Expand Up @@ -560,7 +561,7 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
manifestInfo.Manifests[i] = string(data)
}
}
manifests.Manifests = manifestInfo.Manifests
manifests.Manifests = append(manifests.Manifests, manifestInfo.Manifests...)
}

return manifests, nil
Expand Down
Loading