fix(cli): uses DrySource revision for app diff/manifests with sourceHydrator (#23817) (#24670)
Some checks are pending
Integration tests / Run end-to-end tests (push) Blocked by required conditions
Integration tests / changes (push) Waiting to run
Integration tests / Ensure Go modules synchronicity (push) Blocked by required conditions
Integration tests / Build & cache Go code (push) Blocked by required conditions
Integration tests / Lint Go code (push) Blocked by required conditions
Integration tests / Run unit tests for Go packages (push) Blocked by required conditions
Integration tests / Run unit tests with -race for Go packages (push) Blocked by required conditions
Integration tests / Check changes to generated code (push) Blocked by required conditions
Integration tests / Build, test & lint UI code (push) Blocked by required conditions
Integration tests / shellcheck (push) Waiting to run
Integration tests / Process & analyze test artifacts (push) Blocked by required conditions
Integration tests / E2E Tests - Composite result (push) Blocked by required conditions
Code scanning - action / CodeQL-Build (push) Waiting to run
Image / set-vars (push) Waiting to run
Image / build-only (push) Blocked by required conditions
Image / build-and-publish (push) Blocked by required conditions
Image / build-and-publish-provenance (push) Blocked by required conditions
Image / Deploy (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

Signed-off-by: Aditya Raj <adityaraj10600@gmail.com>
This commit is contained in:
Aditya Raj 2026-04-21 22:21:39 +05:30 committed by GitHub
parent b01aa188fd
commit 6256abf182
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 1 deletions

View file

@ -535,7 +535,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()
}
if q.GetRevision() != "" {
source.TargetRevision = q.GetRevision()
}

View file

@ -2716,6 +2716,39 @@ func TestGetManifests_WithNoCache(t *testing.T) {
require.NoError(t, err)
}
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{{