mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
URL based configuration for git exec timeouts and git submodule cloning
Adds a number of user-accessable options for configuring internal git resource cloning behavior. - Git commands are executed with a configurable timeout by including a parameter like "?timeout=2m30s" in the resource URL. This can improve cloning a large repository, or over a slow network. - Git submodule cloning can be disabled by including a parameter like "?submodules=false" in the resource URL. - Switch the overall query parsing to use url.Parse() and be more extensible.
This commit is contained in:
@@ -12,9 +12,6 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/internal/utils"
|
||||
)
|
||||
|
||||
// Arbitrary, but non-infinite, timeout for running commands.
|
||||
const defaultDuration = 27 * time.Second
|
||||
|
||||
// gitRunner runs the external git binary.
|
||||
type gitRunner struct {
|
||||
gitProgram string
|
||||
@@ -24,7 +21,7 @@ type gitRunner struct {
|
||||
|
||||
// newCmdRunner returns a gitRunner if it can find the binary.
|
||||
// It also creats a temp directory for cloning repos.
|
||||
func newCmdRunner() (*gitRunner, error) {
|
||||
func newCmdRunner(timeout time.Duration) (*gitRunner, error) {
|
||||
gitProgram, err := exec.LookPath("git")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "no 'git' program on path")
|
||||
@@ -35,7 +32,7 @@ func newCmdRunner() (*gitRunner, error) {
|
||||
}
|
||||
return &gitRunner{
|
||||
gitProgram: gitProgram,
|
||||
duration: defaultDuration,
|
||||
duration: timeout,
|
||||
dir: dir,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user