diff --git a/pkg/git/fetch_test.go b/pkg/git/fetch_test.go index a0784f69d..2494688a3 100644 --- a/pkg/git/fetch_test.go +++ b/pkg/git/fetch_test.go @@ -108,6 +108,7 @@ func testGitCheckout(t *testing.T, when spec.G, it spec.S) { }) it("initializes submodules", func() { + fetcher.InitializeSubmodules = true err := fetcher.Fetch(testDir, "https://github.com/git-fixtures/submodule", "master", metadataDir) require.NoError(t, err) diff --git a/pkg/git/remote_git_resolver.go b/pkg/git/remote_git_resolver.go index 6aa366403..af263f840 100644 --- a/pkg/git/remote_git_resolver.go +++ b/pkg/git/remote_git_resolver.go @@ -26,10 +26,11 @@ func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1 if err != nil { return corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: sourceConfig.Git.URL, - Revision: sourceConfig.Git.Revision, - Type: corev1alpha1.Unknown, - SubPath: sourceConfig.SubPath, + URL: sourceConfig.Git.URL, + Revision: sourceConfig.Git.Revision, + Type: corev1alpha1.Unknown, + SubPath: sourceConfig.SubPath, + InitializeSubmodules: sourceConfig.Git.InitializeSubmodules, }, }, nil } @@ -38,10 +39,11 @@ func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1 if ref.Name().Short() == sourceConfig.Git.Revision { return corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: sourceConfig.Git.URL, - Revision: ref.Hash().String(), - Type: sourceType(ref), - SubPath: sourceConfig.SubPath, + URL: sourceConfig.Git.URL, + Revision: ref.Hash().String(), + Type: sourceType(ref), + SubPath: sourceConfig.SubPath, + InitializeSubmodules: sourceConfig.Git.InitializeSubmodules, }, }, nil } @@ -49,10 +51,11 @@ func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1 return corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: sourceConfig.Git.URL, - Revision: sourceConfig.Git.Revision, - Type: corev1alpha1.Commit, - SubPath: sourceConfig.SubPath, + URL: sourceConfig.Git.URL, + Revision: sourceConfig.Git.Revision, + Type: corev1alpha1.Commit, + SubPath: sourceConfig.SubPath, + InitializeSubmodules: sourceConfig.Git.InitializeSubmodules, }, }, nil } diff --git a/pkg/reconciler/sourceresolver/sourceresolver_test.go b/pkg/reconciler/sourceresolver/sourceresolver_test.go index 439a93463..2be7762b3 100644 --- a/pkg/reconciler/sourceresolver/sourceresolver_test.go +++ b/pkg/reconciler/sourceresolver/sourceresolver_test.go @@ -77,8 +77,9 @@ func testSourceResolver(t *testing.T, when spec.G, it spec.S) { ServiceAccountName: serviceAccount, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ - URL: "https://github.com/build-me", - Revision: "1234", + URL: "https://github.com/build-me", + Revision: "1234", + InitializeSubmodules: true, }, }, }, @@ -86,9 +87,10 @@ func testSourceResolver(t *testing.T, when spec.G, it spec.S) { resolvedSource := corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: "https://example.com/something", - Revision: "abcdef", - Type: corev1alpha1.Branch, + URL: "https://example.com/something", + Revision: "abcdef", + Type: corev1alpha1.Branch, + InitializeSubmodules: true, }, }