Skip to content

Commit

Permalink
Gitcloner recurses submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
manno committed Jun 26, 2024
1 parent 71fcf47 commit f222577
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions internal/cmd/agent/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func createClientConfigFromSecret(secret *corev1.Secret, trustSystemStoreCAs boo
token := string(data[Token])

if trustSystemStoreCAs { // Save a request to the API server URL if system CAs are not to be trusted.
// NOTE(manno): client-go will use the system trust store even if a CA is configured. So, why do this?
if _, err := http.Get(apiServerURL); err == nil {
apiServerCA = nil
}
Expand Down
22 changes: 12 additions & 10 deletions internal/cmd/cli/gitcloner/cloner.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,25 @@ func (c *Cloner) CloneRepo(opts *GitCloner) error {

func cloneBranch(opts *GitCloner, auth transport.AuthMethod, caBundle []byte) error {
_, err := plainClone(opts.Path, false, &git.CloneOptions{
URL: opts.Repo,
Auth: auth,
InsecureSkipTLS: opts.InsecureSkipTLS,
CABundle: caBundle,
SingleBranch: true,
ReferenceName: plumbing.ReferenceName(opts.Branch),
URL: opts.Repo,
Auth: auth,
InsecureSkipTLS: opts.InsecureSkipTLS,
CABundle: caBundle,
SingleBranch: true,
ReferenceName: plumbing.ReferenceName(opts.Branch),
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
})

return err
}

func cloneRevision(opts *GitCloner, auth transport.AuthMethod, caBundle []byte) error {
r, err := plainClone(opts.Path, false, &git.CloneOptions{
URL: opts.Repo,
Auth: auth,
InsecureSkipTLS: opts.InsecureSkipTLS,
CABundle: caBundle,
URL: opts.Repo,
Auth: auth,
InsecureSkipTLS: opts.InsecureSkipTLS,
CABundle: caBundle,
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
})
if err != nil {
return err
Expand Down
17 changes: 10 additions & 7 deletions internal/cmd/cli/gitcloner/cloner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ udiSlDctMM/X3ZM2JN5M1rtAJ2WR3ZQtmWbOjZAbG2Eq
Branch: "master",
},
expectedCloneOpts: &git.CloneOptions{
URL: "repo",
SingleBranch: true,
ReferenceName: "master",
URL: "repo",
SingleBranch: true,
ReferenceName: "master",
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
},
},
"branch basic auth": {
Expand All @@ -104,6 +105,7 @@ udiSlDctMM/X3ZM2JN5M1rtAJ2WR3ZQtmWbOjZAbG2Eq
Username: "user",
Password: passwordFileContent,
},
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
},
},
"branch ssh auth": {
Expand All @@ -114,10 +116,11 @@ udiSlDctMM/X3ZM2JN5M1rtAJ2WR3ZQtmWbOjZAbG2Eq
SSHPrivateKeyFile: sshPrivateKeyFile,
},
expectedCloneOpts: &git.CloneOptions{
URL: "ssh://git@localhost/test/test-repo",
SingleBranch: true,
ReferenceName: "master",
Auth: sshAuth,
URL: "ssh://git@localhost/test/test-repo",
SingleBranch: true,
ReferenceName: "master",
Auth: sshAuth,
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
},
},
"password file does not exist": {
Expand Down

0 comments on commit f222577

Please sign in to comment.