Skip to content

Commit

Permalink
update source resolver
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Kennedy <ktom@vmware.com>
  • Loading branch information
tomkennedy513 committed Oct 24, 2023
1 parent 812ba5d commit 809ad17
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions pkg/git/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
27 changes: 15 additions & 12 deletions pkg/git/remote_git_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -38,21 +39,23 @@ 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
}
}

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
}
Expand Down
12 changes: 7 additions & 5 deletions pkg/reconciler/sourceresolver/sourceresolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,20 @@ 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,
},
},
},
}

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,
},
}

Expand Down

0 comments on commit 809ad17

Please sign in to comment.