Skip to content

Commit 6256abf

Browse files
authored
fix(cli): uses DrySource revision for app diff/manifests with sourceHydrator (#23817) (#24670)
Signed-off-by: Aditya Raj <adityaraj10600@gmail.com>
1 parent b01aa18 commit 6256abf

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

server/application/application.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,14 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
535535
}
536536
sources = appSpec.GetSources()
537537
} else {
538-
source := a.Spec.GetSource()
538+
// For sourceHydrator applications, use the dry source to generate manifests
539+
var source v1alpha1.ApplicationSource
540+
if a.Spec.SourceHydrator != nil {
541+
source = a.Spec.SourceHydrator.GetDrySource()
542+
} else {
543+
source = a.Spec.GetSource()
544+
}
545+
539546
if q.GetRevision() != "" {
540547
source.TargetRevision = q.GetRevision()
541548
}

server/application/application_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,39 @@ func TestGetManifests_WithNoCache(t *testing.T) {
27162716
require.NoError(t, err)
27172717
}
27182718

2719+
func TestGetManifests_SourceHydrator(t *testing.T) {
2720+
testApp := newTestApp()
2721+
testApp.Spec.SourceHydrator = &v1alpha1.SourceHydrator{
2722+
DrySource: v1alpha1.DrySource{
2723+
RepoURL: "https://github.com/org/dry-repo",
2724+
Path: "manifests/dry",
2725+
TargetRevision: "main",
2726+
},
2727+
SyncSource: v1alpha1.SyncSource{
2728+
Path: "manifests/sync",
2729+
},
2730+
}
2731+
2732+
appServer := newTestAppServer(t, testApp)
2733+
2734+
mockRepoServiceClient := mocks.RepoServerServiceClient{}
2735+
2736+
mockRepoServiceClient.On("GenerateManifest", mock.Anything, mock.MatchedBy(func(mr *apiclient.ManifestRequest) bool {
2737+
return mr.Repo.Repo == "https://github.com/org/dry-repo" &&
2738+
mr.ApplicationSource.Path == "manifests/dry" &&
2739+
mr.Revision == "some-revision"
2740+
})).Return(&apiclient.ManifestResponse{}, nil)
2741+
2742+
appServer.repoClientset = &mocks.Clientset{RepoServerServiceClient: &mockRepoServiceClient}
2743+
2744+
_, err := appServer.GetManifests(t.Context(), &application.ApplicationManifestQuery{
2745+
Name: &testApp.Name,
2746+
Revision: ptr.To("some-revision"),
2747+
})
2748+
require.NoError(t, err)
2749+
mockRepoServiceClient.AssertExpectations(t)
2750+
}
2751+
27192752
func TestRollbackApp(t *testing.T) {
27202753
testApp := newTestApp()
27212754
testApp.Status.History = []v1alpha1.RevisionHistory{{

0 commit comments

Comments
 (0)