Skip to content

Commit c3ef78c

Browse files
committed
Merge remote-tracking branch 'origin/upstream'
Signed-off-by: Elias Rami <[email protected]>
2 parents d42880c + 3c12c01 commit c3ef78c

File tree

5 files changed

+1119
-0
lines changed

5 files changed

+1119
-0
lines changed

cmd/util/app_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ func Test_setAppSpecOptions(t *testing.T) {
369369
require.NoError(t, f.SetFlag("sync-source-path", "apps"))
370370
assert.Equal(t, "apps", f.spec.SourceHydrator.SyncSource.Path)
371371

372+
// Test sync-source-repo flag - this is the new field for different repository support
373+
require.NoError(t, f.SetFlag("sync-source-repo", "https://github.com/argoproj/gitops-manifests"))
374+
assert.Equal(t, "https://github.com/argoproj/gitops-manifests", f.spec.SourceHydrator.SyncSource.RepoURL)
375+
372376
require.NoError(t, f.SetFlag("hydrate-to-branch", "env/test-next"))
373377
assert.Equal(t, "env/test-next", f.spec.SourceHydrator.HydrateTo.TargetBranch)
374378

controller/hydrator/hydrator_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,63 @@ func TestValidateApplications_RootPath(t *testing.T) {
709709
require.ErrorContains(t, errs[app.QualifiedName()], "app is configured to hydrate to the repository root")
710710
}
711711

712+
// TestValidateApplications_SyncSourceRepoNotPermitted tests that the sync source repo
713+
// must be permitted in the project. When SyncSource.RepoURL is set to a different repo,
714+
// that repo must be permitted. This tests PR #25464 code.
715+
func TestValidateApplications_SyncSourceRepoNotPermitted(t *testing.T) {
716+
t.Parallel()
717+
d := mocks.NewDependencies(t)
718+
app := newTestApp("test-app")
719+
// Set a different sync source repo URL that is not permitted in the project
720+
// The dry source repo (https://example.com/repo) is permitted, but the sync source repo is not
721+
app.Spec.SourceHydrator.SyncSource.RepoURL = "https://example.com/not-permitted-repo"
722+
// Project permits https://example.com/repo (dry source) but not the sync source repo
723+
proj := newTestProject()
724+
d.EXPECT().GetProcessableAppProj(app).Return(proj, nil).Once()
725+
h := &Hydrator{dependencies: d}
726+
727+
projects, errs := h.validateApplications([]*v1alpha1.Application{app})
728+
require.Nil(t, projects)
729+
require.Len(t, errs, 1)
730+
// When SyncSource.RepoURL is set, GetSource() returns that repo URL, so the first validation check fails
731+
require.ErrorContains(t, errs[app.QualifiedName()], "application repo https://example.com/not-permitted-repo is not permitted in project")
732+
}
733+
734+
// TestValidateApplications_DestinationRepoPermitted tests that validation passes when
735+
// the destination repo (sync source) is permitted in the project
736+
func TestValidateApplications_DestinationRepoPermitted(t *testing.T) {
737+
t.Parallel()
738+
d := mocks.NewDependencies(t)
739+
app := newTestApp("test-app")
740+
// Set sync source repo URL that IS permitted in the project
741+
app.Spec.SourceHydrator.SyncSource.RepoURL = "https://example.com/repo"
742+
// Project permits https://example.com/repo
743+
proj := newTestProject()
744+
d.EXPECT().GetProcessableAppProj(app).Return(proj, nil).Once()
745+
h := &Hydrator{dependencies: d}
746+
747+
projects, errs := h.validateApplications([]*v1alpha1.Application{app})
748+
require.NotNil(t, projects)
749+
require.Empty(t, errs)
750+
}
751+
752+
// TestValidateApplications_DestinationRepoSameAsDrySource tests that validation passes when
753+
// the sync source repo URL is empty (defaults to dry source repo)
754+
func TestValidateApplications_DestinationRepoSameAsDrySource(t *testing.T) {
755+
t.Parallel()
756+
d := mocks.NewDependencies(t)
757+
app := newTestApp("test-app")
758+
// Empty sync source repo URL - should use dry source repo URL which is permitted
759+
app.Spec.SourceHydrator.SyncSource.RepoURL = ""
760+
proj := newTestProject()
761+
d.EXPECT().GetProcessableAppProj(app).Return(proj, nil).Once()
762+
h := &Hydrator{dependencies: d}
763+
764+
projects, errs := h.validateApplications([]*v1alpha1.Application{app})
765+
require.NotNil(t, projects)
766+
require.Empty(t, errs)
767+
}
768+
712769
func TestValidateApplications_DuplicateDestination(t *testing.T) {
713770
t.Parallel()
714771
d := mocks.NewDependencies(t)

docs/operator-manual/health.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ with at least one value for `hostname` or `IP`.
1616
### Ingress
1717
* The `status.loadBalancer.ingress` list is non-empty, with at least one value for `hostname` or `IP`.
1818

19+
### CronJob
20+
* If the last scheduled job for this CronJob failed, the CronJob will be marked as "Degraded"
21+
* If the last scheduled job for this CronJob is running, the CronJob will be marked as "Progressing"
22+
1923
### Job
2024
* If job `.spec.suspended` is set to 'true', then the job and app health will be marked as suspended.
25+
2126
### PersistentVolumeClaim
2227
* The `status.phase` is `Bound`
2328

0 commit comments

Comments
 (0)