Skip to content

Commit 64bd34f

Browse files
committed
Use bipolarity option in gitrepo and ocirepo
Use the bipolarity condition options in OCIRepository and GitRepository reconcilers. Signed-off-by: Sunny <[email protected]>
1 parent e5d3aa3 commit 64bd34f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

controllers/gitrepository_controller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
194194
summarizeHelper := summarize.NewHelper(r.EventRecorder, patchHelper)
195195
summarizeOpts := []summarize.Option{
196196
summarize.WithConditions(gitRepositoryReadyCondition),
197+
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
197198
summarize.WithReconcileResult(recResult),
198199
summarize.WithReconcileError(retErr),
199200
summarize.WithIgnoreNotFound(),
@@ -430,6 +431,15 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
430431
errors.New("libgit2 managed transport not initialized"), "Libgit2TransportNotEnabled",
431432
)
432433
}
434+
435+
// Remove previously failed source verification status conditions. The
436+
// failing verification should be recalculated. But an existing successful
437+
// verification need not be removed as it indicates verification of previous
438+
// version.
439+
if conditions.IsFalse(obj, sourcev1.SourceVerifiedCondition) {
440+
conditions.Delete(obj, sourcev1.SourceVerifiedCondition)
441+
}
442+
433443
// Configure authentication strategy to access the source
434444
var authOpts *git.AuthOptions
435445
var err error

controllers/ocirepository_controller.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ func (r *OCIRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
194194
summarizeHelper := summarize.NewHelper(r.EventRecorder, patchHelper)
195195
summarizeOpts := []summarize.Option{
196196
summarize.WithConditions(ociRepositoryReadyCondition),
197+
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
197198
summarize.WithReconcileResult(recResult),
198199
summarize.WithReconcileError(retErr),
199200
summarize.WithIgnoreNotFound(),
@@ -297,6 +298,14 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, obj *sour
297298
ctxTimeout, cancel := context.WithTimeout(ctx, obj.Spec.Timeout.Duration)
298299
defer cancel()
299300

301+
// Remove previously failed source verification status conditions. The
302+
// failing verification should be recalculated. But an existing successful
303+
// verification need not be removed as it indicates verification of previous
304+
// version.
305+
if conditions.IsFalse(obj, sourcev1.SourceVerifiedCondition) {
306+
conditions.Delete(obj, sourcev1.SourceVerifiedCondition)
307+
}
308+
300309
options := r.craneOptions(ctxTimeout, obj.Spec.Insecure)
301310

302311
// Generate the registry credential keychain either from static credentials or using cloud OIDC

0 commit comments

Comments
 (0)