Skip to content
Open
Show file tree
Hide file tree
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: 8 additions & 1 deletion server/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,14 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
}
sources = appSpec.GetSources()
} else {
source := a.Spec.GetSource()
// For sourceHydrator applications, use the dry source to generate manifests
var source v1alpha1.ApplicationSource
if a.Spec.SourceHydrator != nil {
source = a.Spec.SourceHydrator.GetDrySource()
} else {
source = a.Spec.GetSource()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
source = a.Spec.GetSource()
source = a.Spec.GetSource()

how will this work for a multi-source application?

Copy link
Member

Choose a reason for hiding this comment

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

shouldn't there be changes to be made at line 514 to handle multi-source application logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hii @nitishfy,
[HasMultipleSources()] returns false for SourceHydrator apps (since it checks spec.SourceHydrator == nil) and it handles multiple source case well
now single-source apps go to the else branch and here it got divided into sourceHydrator and non-sourceHydrator.
Multi-source apps will take the if branch(line 514) and never reach line 529.

Isn't sourceHydrator is mutually exclusive with multi-source, they can't be used together.

Copy link
Member

Choose a reason for hiding this comment

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

Correct, they're mutually exclusive

}

if q.GetRevision() != "" {
source.TargetRevision = q.GetRevision()
}
Expand Down
33 changes: 33 additions & 0 deletions server/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,39 @@ func TestGetManifests_WithNoCache(t *testing.T) {
mockRepoServiceClient.AssertExpectations(t)
}

func TestGetManifests_SourceHydrator(t *testing.T) {
testApp := newTestApp()
testApp.Spec.SourceHydrator = &v1alpha1.SourceHydrator{
DrySource: v1alpha1.DrySource{
RepoURL: "https://github.com/org/dry-repo",
Path: "manifests/dry",
TargetRevision: "main",
},
SyncSource: v1alpha1.SyncSource{
Path: "manifests/sync",
},
}

appServer := newTestAppServer(t, testApp)

mockRepoServiceClient := mocks.RepoServerServiceClient{}

mockRepoServiceClient.On("GenerateManifest", mock.Anything, mock.MatchedBy(func(mr *apiclient.ManifestRequest) bool {
return mr.Repo.Repo == "https://github.com/org/dry-repo" &&
mr.ApplicationSource.Path == "manifests/dry" &&
mr.Revision == "some-revision"
})).Return(&apiclient.ManifestResponse{}, nil)

appServer.repoClientset = &mocks.Clientset{RepoServerServiceClient: &mockRepoServiceClient}

_, err := appServer.GetManifests(t.Context(), &application.ApplicationManifestQuery{
Name: &testApp.Name,
Revision: ptr.To("some-revision"),
})
require.NoError(t, err)
mockRepoServiceClient.AssertExpectations(t)
}

func TestRollbackApp(t *testing.T) {
testApp := newTestApp()
testApp.Status.History = []v1alpha1.RevisionHistory{{
Expand Down
Loading