Re-instantiate non-optimized clone fallback
This adds a bit back which got removed in
69f567bdc7
, as there are reasons for the
controller to perform a non-optimized clone.
However, we always want to attempt the optimized version first without
it being put behind a feature gate. Which was the original intent of
the referenced commit.
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
parent
c758e666b7
commit
2f4b200571
|
@ -536,7 +536,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
|
||||||
// Persist the ArtifactSet.
|
// Persist the ArtifactSet.
|
||||||
*includes = *artifacts
|
*includes = *artifacts
|
||||||
|
|
||||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
|
c, err := r.gitCheckout(ctx, obj, authOpts, dir, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sreconcile.ResultEmpty, err
|
return sreconcile.ResultEmpty, err
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
|
||||||
|
|
||||||
// If we can't skip the reconciliation, checkout again without any
|
// If we can't skip the reconciliation, checkout again without any
|
||||||
// optimization.
|
// optimization.
|
||||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
|
c, err := r.gitCheckout(ctx, obj, authOpts, dir, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sreconcile.ResultEmpty, err
|
return sreconcile.ResultEmpty, err
|
||||||
}
|
}
|
||||||
|
@ -777,7 +777,7 @@ func (r *GitRepositoryReconciler) reconcileInclude(ctx context.Context, sp *patc
|
||||||
// gitCheckout builds checkout options with the given configurations and
|
// gitCheckout builds checkout options with the given configurations and
|
||||||
// performs a git checkout.
|
// performs a git checkout.
|
||||||
func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
||||||
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string) (*git.Commit, error) {
|
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string, optimized bool) (*git.Commit, error) {
|
||||||
// Configure checkout strategy.
|
// Configure checkout strategy.
|
||||||
cloneOpts := repository.CloneConfig{
|
cloneOpts := repository.CloneConfig{
|
||||||
RecurseSubmodules: obj.Spec.RecurseSubmodules,
|
RecurseSubmodules: obj.Spec.RecurseSubmodules,
|
||||||
|
@ -794,7 +794,7 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
||||||
// Only if the object has an existing artifact in storage, attempt to
|
// Only if the object has an existing artifact in storage, attempt to
|
||||||
// short-circuit clone operation. reconcileStorage has already verified
|
// short-circuit clone operation. reconcileStorage has already verified
|
||||||
// that the artifact exists.
|
// that the artifact exists.
|
||||||
if conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
|
if optimized && conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
|
||||||
if artifact := obj.GetArtifact(); artifact != nil {
|
if artifact := obj.GetArtifact(); artifact != nil {
|
||||||
cloneOpts.LastObservedCommit = artifact.Revision
|
cloneOpts.LastObservedCommit = artifact.Revision
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue