Add GitShallowClone feature

This feature enables the use of shallow clones when pulling source from
Git repositories.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
Paulo Gomes 2022-11-24 13:57:47 +00:00
parent 6d639f3bcd
commit e846e29458
No known key found for this signature in database
GPG Key ID: 9995233870E99BEE
2 changed files with 12 additions and 0 deletions

View File

@ -298,6 +298,10 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr
opts.Branch = ref.Branch
}
if enabled, _ := r.features[features.GitShallowClone]; enabled {
opts.ShallowClone = true
}
// Use the git operations timeout for the repo.
cloneCtx, cancel := context.WithTimeout(ctx, origin.Spec.Timeout.Duration)
defer cancel()

View File

@ -32,6 +32,10 @@ const (
// When enabled, libgit2 won't be initialized, nor will any git2go cgo
// code be called.
ForceGoGitImplementation = "ForceGoGitImplementation"
// GitShallowClone enables the use of shallow clones when pulling source from
// Git repositories.
GitShallowClone = "GitShallowClone"
)
var features = map[string]bool{
@ -42,6 +46,10 @@ var features = map[string]bool{
// ForceGoGitImplementation
// opt-out from v0.27
ForceGoGitImplementation: true,
// GitShallowClone
// opt-in from v0.28
GitShallowClone: false,
}
// DefaultFeatureGates contains a list of all supported feature gates and