diff --git a/controllers/gitrepository_controller_test.go b/controllers/gitrepository_controller_test.go index 59d17ea1..7b6aeba3 100644 --- a/controllers/gitrepository_controller_test.go +++ b/controllers/gitrepository_controller_test.go @@ -771,6 +771,21 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) { *conditions.TrueCondition(meta.ReadyCondition, meta.SucceededReason, "stored artifact for revision 'main/revision'"), }, }, + { + name: "source ignore for subdir ignore patterns", + dir: "testdata/git/repowithsubdirs", + beforeFunc: func(obj *sourcev1.GitRepository) { + obj.Spec.Interval = metav1.Duration{Duration: interval} + }, + afterFunc: func(t *WithT, obj *sourcev1.GitRepository) { + t.Expect(obj.GetArtifact()).ToNot(BeNil()) + t.Expect(obj.GetArtifact().Checksum).To(Equal("29186e024dde5a414cfc990829c6b2e85f6b3bd2d950f50ca9f418f5d2261d79")) + }, + want: sreconcile.ResultSuccess, + assertConditions: []metav1.Condition{ + *conditions.TrueCondition(meta.ReadyCondition, meta.SucceededReason, "stored artifact for revision 'main/revision'"), + }, + }, { name: "Removes ArtifactOutdatedCondition after creating new artifact", dir: "testdata/git/repository", diff --git a/controllers/testdata/git/repowithsubdirs/.sourceignore b/controllers/testdata/git/repowithsubdirs/.sourceignore new file mode 100644 index 00000000..1753c918 --- /dev/null +++ b/controllers/testdata/git/repowithsubdirs/.sourceignore @@ -0,0 +1,6 @@ +# Exclude all +/* + +# Include manifest directories +!/apps/ +!/clusters/ diff --git a/controllers/testdata/git/repowithsubdirs/apps/manifest.yaml b/controllers/testdata/git/repowithsubdirs/apps/manifest.yaml new file mode 100644 index 00000000..fd6e0f90 --- /dev/null +++ b/controllers/testdata/git/repowithsubdirs/apps/manifest.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: apps diff --git a/controllers/testdata/git/repowithsubdirs/clusters/manifest.yaml b/controllers/testdata/git/repowithsubdirs/clusters/manifest.yaml new file mode 100644 index 00000000..84a8f643 --- /dev/null +++ b/controllers/testdata/git/repowithsubdirs/clusters/manifest.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: clusters diff --git a/controllers/testdata/git/repowithsubdirs/foo.txt b/controllers/testdata/git/repowithsubdirs/foo.txt new file mode 100644 index 00000000..e69de29b