Skip to content

Commit 821e0d5

Browse files
committed
uses DrySource revision for app diff/manifests with sourceHydrator
Signed-off-by: Aditya Raj <[email protected]>
1 parent f960274 commit 821e0d5

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

server/application/application.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,20 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
521521
}
522522
sources = appSpec.GetSources()
523523
} else {
524-
source := a.Spec.GetSource()
525-
if q.GetRevision() != "" {
526-
source.TargetRevision = q.GetRevision()
524+
// For sourceHydrator applications, use the dry source to generate manifests
525+
if a.Spec.SourceHydrator != nil {
526+
source := a.Spec.SourceHydrator.GetDrySource()
527+
if q.GetRevision() != "" {
528+
source.TargetRevision = q.GetRevision()
529+
}
530+
sources = append(sources, source)
531+
} else {
532+
source := a.Spec.GetSource()
533+
if q.GetRevision() != "" {
534+
source.TargetRevision = q.GetRevision()
535+
}
536+
sources = append(sources, source)
527537
}
528-
sources = append(sources, source)
529538
}
530539

531540
// Store the map of all sources having ref field into a map for applications with sources field

server/application/application_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,6 +2174,39 @@ func TestGetManifests_WithNoCache(t *testing.T) {
21742174
mockRepoServiceClient.AssertExpectations(t)
21752175
}
21762176

2177+
func TestGetManifests_SourceHydrator(t *testing.T) {
2178+
testApp := newTestApp()
2179+
testApp.Spec.SourceHydrator = &v1alpha1.SourceHydrator{
2180+
DrySource: v1alpha1.DrySource{
2181+
RepoURL: "https://github.com/org/dry-repo",
2182+
Path: "manifests/dry",
2183+
TargetRevision: "main",
2184+
},
2185+
SyncSource: v1alpha1.SyncSource{
2186+
Path: "manifests/sync",
2187+
},
2188+
}
2189+
2190+
appServer := newTestAppServer(t, testApp)
2191+
2192+
mockRepoServiceClient := mocks.RepoServerServiceClient{}
2193+
2194+
mockRepoServiceClient.On("GenerateManifest", mock.Anything, mock.MatchedBy(func(mr *apiclient.ManifestRequest) bool {
2195+
return mr.Repo.Repo == "https://github.com/org/dry-repo" &&
2196+
mr.ApplicationSource.Path == "manifests/dry" &&
2197+
mr.Revision == "some-revision"
2198+
})).Return(&apiclient.ManifestResponse{}, nil)
2199+
2200+
appServer.repoClientset = &mocks.Clientset{RepoServerServiceClient: &mockRepoServiceClient}
2201+
2202+
_, err := appServer.GetManifests(t.Context(), &application.ApplicationManifestQuery{
2203+
Name: &testApp.Name,
2204+
Revision: ptr.To("some-revision"),
2205+
})
2206+
require.NoError(t, err)
2207+
mockRepoServiceClient.AssertExpectations(t)
2208+
}
2209+
21772210
func TestRollbackApp(t *testing.T) {
21782211
testApp := newTestApp()
21792212
testApp.Status.History = []v1alpha1.RevisionHistory{{

0 commit comments

Comments
 (0)